Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(442)

Side by Side Diff: recipe_modules/bot_update/resources/bot_update.py

Issue 2448983004: Log error message if os.rename fails (Closed)
Patch Set: Log error message if os.rename fails Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # TODO(hinoka): Use logging. 6 # TODO(hinoka): Use logging.
7 7
8 import cStringIO 8 import cStringIO
9 import codecs 9 import codecs
10 import copy 10 import copy
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 return solutions 292 return solutions
293 293
294 294
295 def remove(target): 295 def remove(target):
296 """Remove a target by moving it into build.dead.""" 296 """Remove a target by moving it into build.dead."""
297 dead_folder = path.join(BUILDER_DIR, 'build.dead') 297 dead_folder = path.join(BUILDER_DIR, 'build.dead')
298 if not path.exists(dead_folder): 298 if not path.exists(dead_folder):
299 os.makedirs(dead_folder) 299 os.makedirs(dead_folder)
300 dest = path.join(dead_folder, uuid.uuid4().hex) 300 dest = path.join(dead_folder, uuid.uuid4().hex)
301 print 'Marking for removal %s => %s' % (target, dest) 301 print 'Marking for removal %s => %s' % (target, dest)
302 os.rename(target, dest) 302 try:
303 os.rename(target, dest)
304 except Exception as e:
305 print 'Error renaming %s to %s: %s' % (target, dest, str(e))
306 raise
303 307
304 308
305 def ensure_no_checkout(dir_names): 309 def ensure_no_checkout(dir_names):
306 """Ensure that there is no undesired checkout under build/.""" 310 """Ensure that there is no undesired checkout under build/."""
307 build_dir = os.getcwd() 311 build_dir = os.getcwd()
308 has_checkout = any(path.exists(path.join(build_dir, dir_name, '.git')) 312 has_checkout = any(path.exists(path.join(build_dir, dir_name, '.git'))
309 for dir_name in dir_names) 313 for dir_name in dir_names)
310 if has_checkout: 314 if has_checkout:
311 for filename in os.listdir(build_dir): 315 for filename in os.listdir(build_dir):
312 deletion_target = path.join(build_dir, filename) 316 deletion_target = path.join(build_dir, filename)
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 # download patch failure is still an infra problem. 1100 # download patch failure is still an infra problem.
1097 if e.code == 3: 1101 if e.code == 3:
1098 # Patch download problem. 1102 # Patch download problem.
1099 return 87 1103 return 87
1100 # Genuine patch problem. 1104 # Genuine patch problem.
1101 return 88 1105 return 88
1102 1106
1103 1107
1104 if __name__ == '__main__': 1108 if __name__ == '__main__':
1105 sys.exit(main()) 1109 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698