| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 shutil | 9 import shutil |
| 10 import subprocess | 10 import subprocess |
| 11 import sys | 11 import sys |
| 12 import tempfile | 12 import tempfile |
| 13 | 13 |
| 14 def run_quiet(*args): | 14 def run_quiet(*args): |
| 15 """Run 'expand' supressing noisy output. Returns returncode from process.""" | 15 """Run 'expand' suppressing noisy output. Returns returncode from process.""" |
| 16 popen = subprocess.Popen(args, stdout=subprocess.PIPE) | 16 popen = subprocess.Popen(args, stdout=subprocess.PIPE) |
| 17 out, _ = popen.communicate() | 17 out, _ = popen.communicate() |
| 18 if popen.returncode: | 18 if popen.returncode: |
| 19 # expand emits errors to stdout, so if we fail, then print that out. | 19 # expand emits errors to stdout, so if we fail, then print that out. |
| 20 print out | 20 print out |
| 21 return popen.returncode | 21 return popen.returncode |
| 22 | 22 |
| 23 def main(): | 23 def main(): |
| 24 if len(sys.argv) != 4: | 24 if len(sys.argv) != 4: |
| 25 print 'Usage: extract_from_cab.py cab_path archived_file output_dir' | 25 print 'Usage: extract_from_cab.py cab_path archived_file output_dir' |
| (...skipping 28 matching lines...) Expand all Loading... |
| 54 # The expand utility preserves the modification date and time of the archived | 54 # The expand utility preserves the modification date and time of the archived |
| 55 # file. Touch the extracted file. This helps build systems that compare the | 55 # file. Touch the extracted file. This helps build systems that compare the |
| 56 # modification times of input and output files to determine whether to do an | 56 # modification times of input and output files to determine whether to do an |
| 57 # action. | 57 # action. |
| 58 os.utime(os.path.join(output_dir, archived_file), None) | 58 os.utime(os.path.join(output_dir, archived_file), None) |
| 59 return 0 | 59 return 0 |
| 60 | 60 |
| 61 | 61 |
| 62 if __name__ == '__main__': | 62 if __name__ == '__main__': |
| 63 sys.exit(main()) | 63 sys.exit(main()) |
| OLD | NEW |