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 if kwargs.pop('flag_smart_rmtree', False): |
| 11 # TODO(tandrii): remove this flag and makes this the only implementation. |
| 12 self.m.python( |
| 13 name, |
| 14 self.resource('rmtree.py'), |
| 15 args=[path], |
| 16 **kwargs) |
| 17 return |
10 self.m.python.inline( | 18 self.m.python.inline( |
11 name, | 19 name, |
12 """ | 20 """ |
13 import shutil, sys | 21 import shutil, sys |
14 shutil.rmtree(sys.argv[1]) | 22 shutil.rmtree(sys.argv[1]) |
15 """, | 23 """, |
16 args=[path], | 24 args=[path], |
17 **kwargs) | 25 **kwargs) |
18 | 26 |
19 def copy(self, name, source, dest, step_test_data=None, **kwargs): | 27 def copy(self, name, source, dest, step_test_data=None, **kwargs): |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 if not os.path.isdir(path): | 142 if not os.path.isdir(path): |
135 if os.path.exists(path): | 143 if os.path.exists(path): |
136 print "%s exists but is not a dir" % path | 144 print "%s exists but is not a dir" % path |
137 sys.exit(1) | 145 sys.exit(1) |
138 os.makedirs(path, mode) | 146 os.makedirs(path, mode) |
139 """, | 147 """, |
140 args=[path, str(mode)], | 148 args=[path, str(mode)], |
141 **kwargs | 149 **kwargs |
142 ) | 150 ) |
143 self.m.path.mock_add_paths(path) | 151 self.m.path.mock_add_paths(path) |
OLD | NEW |