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

Side by Side Diff: build/extract_from_cab.py

Issue 8883029: Add automatic retry of cab extraction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 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 """Extracts a single file from a CAB archive.""" 6 """Extracts a single file from a CAB archive."""
7 7
8 import os 8 import os
9 import subprocess 9 import subprocess
10 import sys 10 import sys
11 11
12 12
13 def main(): 13 def main():
14 if len(sys.argv) != 4: 14 if len(sys.argv) != 4:
15 print 'Usage: extract_from_cab.py cab_path archived_file output_dir' 15 print 'Usage: extract_from_cab.py cab_path archived_file output_dir'
16 return 1 16 return 1
17 17
18 [cab_path, archived_file, output_dir] = sys.argv[1:] 18 [cab_path, archived_file, output_dir] = sys.argv[1:]
19 19
20 # Invoke the Windows expand utility to extract the file. 20 # Invoke the Windows expand utility to extract the file.
21 level = subprocess.call( 21 level = subprocess.call(
22 ['expand', cab_path, '-F:' + archived_file, output_dir]) 22 ['expand', cab_path, '-F:' + archived_file, output_dir])
23 if level != 0: 23 if level != 0:
24 return level 24 print 'Cab extraction(%s, %s, %s) failed.' % (
25 cab_path, archived_file, output_dir)
26 print 'Trying a second time.'
27 level = subprocess.call(
28 ['expand', cab_path, '-F:' + archived_file, output_dir])
29 if level != 0:
30 return level
25 31
26 # The expand utility preserves the modification date and time of the archived 32 # The expand utility preserves the modification date and time of the archived
27 # file. Touch the extracted file. This helps build systems that compare the 33 # file. Touch the extracted file. This helps build systems that compare the
28 # modification times of input and output files to determine whether to do an 34 # modification times of input and output files to determine whether to do an
29 # action. 35 # action.
30 os.utime(os.path.join(output_dir, archived_file), None) 36 os.utime(os.path.join(output_dir, archived_file), None)
31 return 0 37 return 0
32 38
33 39
34 if __name__ == '__main__': 40 if __name__ == '__main__':
35 sys.exit(main()) 41 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