| OLD | NEW |
| 1 # Copyright 2016 The LUCI Authors. All rights reserved. | 1 # Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 from recipe_engine import recipe_api | 5 from recipe_engine import recipe_api |
| 6 | 6 |
| 7 class ShutilApi(recipe_api.RecipeApi): | 7 class ShutilApi(recipe_api.RecipeApi): |
| 8 def rmtree(self, path, **kwargs): | 8 def rmtree(self, path, **kwargs): |
| 9 name = kwargs.pop('name', 'rmtree %s' % path) | 9 name = kwargs.pop('name', 'rmtree %s' % path) |
| 10 self.m.python( | 10 self.m.python.inline( |
| 11 name, | 11 name, |
| 12 self.resource('rmtree.py'), | 12 """ |
| 13 import shutil, sys |
| 14 shutil.rmtree(sys.argv[1]) |
| 15 """, |
| 13 args=[path], | 16 args=[path], |
| 14 **kwargs) | 17 **kwargs) |
| 15 | 18 |
| 16 def copy(self, name, source, dest, step_test_data=None, **kwargs): | 19 def copy(self, name, source, dest, step_test_data=None, **kwargs): |
| 17 """Copy a file.""" | 20 """Copy a file.""" |
| 18 return self.m.python.inline( | 21 return self.m.python.inline( |
| 19 name, | 22 name, |
| 20 """ | 23 """ |
| 21 import shutil | 24 import shutil |
| 22 import sys | 25 import sys |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 if not os.path.isdir(path): | 134 if not os.path.isdir(path): |
| 132 if os.path.exists(path): | 135 if os.path.exists(path): |
| 133 print "%s exists but is not a dir" % path | 136 print "%s exists but is not a dir" % path |
| 134 sys.exit(1) | 137 sys.exit(1) |
| 135 os.makedirs(path, mode) | 138 os.makedirs(path, mode) |
| 136 """, | 139 """, |
| 137 args=[path, str(mode)], | 140 args=[path, str(mode)], |
| 138 **kwargs | 141 **kwargs |
| 139 ) | 142 ) |
| 140 self.m.path.mock_add_paths(path) | 143 self.m.path.mock_add_paths(path) |
| OLD | NEW |