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

Side by Side Diff: git_cache.py

Issue 342753003: Don't os.listdir() on a non-existent dir (it raises). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 6 years, 6 months 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 | Annotate | Revision Log
« 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 """A git command for managing a local cache of git repositories.""" 6 """A git command for managing a local cache of git repositories."""
7 7
8 from __future__ import print_function 8 from __future__ import print_function
9 import errno 9 import errno
10 import logging 10 import logging
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 subprocess.call(['zip', '-r', tmp_zipfile, '.'], cwd=self.mirror_path) 392 subprocess.call(['zip', '-r', tmp_zipfile, '.'], cwd=self.mirror_path)
393 gsutil = Gsutil(path=self.gsutil_exe, boto_path=None) 393 gsutil = Gsutil(path=self.gsutil_exe, boto_path=None)
394 dest_name = 'gs://%s/%s/%s.zip' % ( 394 dest_name = 'gs://%s/%s/%s.zip' % (
395 self.bootstrap_bucket, self.basedir, gen_number) 395 self.bootstrap_bucket, self.basedir, gen_number)
396 gsutil.call('cp', tmp_zipfile, dest_name) 396 gsutil.call('cp', tmp_zipfile, dest_name)
397 os.remove(tmp_zipfile) 397 os.remove(tmp_zipfile)
398 398
399 @staticmethod 399 @staticmethod
400 def DeleteTmpPackFiles(path): 400 def DeleteTmpPackFiles(path):
401 pack_dir = os.path.join(path, 'objects', 'pack') 401 pack_dir = os.path.join(path, 'objects', 'pack')
402 if not os.path.isdir(pack_dir):
403 return
402 pack_files = [f for f in os.listdir(pack_dir) if 404 pack_files = [f for f in os.listdir(pack_dir) if
403 f.startswith('.tmp-') or f.startswith('tmp_pack_')] 405 f.startswith('.tmp-') or f.startswith('tmp_pack_')]
404 for f in pack_files: 406 for f in pack_files:
405 f = os.path.join(pack_dir, f) 407 f = os.path.join(pack_dir, f)
406 try: 408 try:
407 os.remove(f) 409 os.remove(f)
408 logging.warn('Deleted stale temporary pack file %s' % f) 410 logging.warn('Deleted stale temporary pack file %s' % f)
409 except OSError: 411 except OSError:
410 logging.warn('Unable to delete temporary pack file %s' % f) 412 logging.warn('Unable to delete temporary pack file %s' % f)
411 413
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 return options, args 581 return options, args
580 582
581 583
582 def main(argv): 584 def main(argv):
583 dispatcher = subcommand.CommandDispatcher(__name__) 585 dispatcher = subcommand.CommandDispatcher(__name__)
584 return dispatcher.execute(OptionParser(), argv) 586 return dispatcher.execute(OptionParser(), argv)
585 587
586 588
587 if __name__ == '__main__': 589 if __name__ == '__main__':
588 sys.exit(main(sys.argv[1:])) 590 sys.exit(main(sys.argv[1:]))
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