OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2015 The PDFium Authors. All rights reserved. | 2 # Copyright 2015 The PDFium 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 import os | 6 import os |
| 7 import subprocess |
7 import sys | 8 import sys |
8 | 9 |
9 def os_name(): | 10 def os_name(): |
10 if sys.platform.startswith('linux'): | 11 if sys.platform.startswith('linux'): |
11 return 'linux' | 12 return 'linux' |
12 if sys.platform.startswith('win'): | 13 if sys.platform.startswith('win'): |
13 return 'win' | 14 return 'win' |
14 if sys.platform.startswith('darwin'): | 15 if sys.platform.startswith('darwin'): |
15 return 'mac' | 16 return 'mac' |
16 raise Exception('Confused, can not determine OS, aborting.') | 17 raise Exception('Confused, can not determine OS, aborting.') |
17 | 18 |
18 | 19 |
| 20 def RunCommand(cmd, redirect_output=False): |
| 21 try: |
| 22 if redirect_output: |
| 23 sys.stdout.write(subprocess.check_output(cmd, stderr=subprocess.STDOUT)) |
| 24 else: |
| 25 subprocess.check_call(cmd) |
| 26 return None |
| 27 except subprocess.CalledProcessError as e: |
| 28 return e |
| 29 |
| 30 |
19 class DirectoryFinder: | 31 class DirectoryFinder: |
20 '''A class for finding directories and paths under either a standalone | 32 '''A class for finding directories and paths under either a standalone |
21 checkout or a chromium checkout of PDFium.''' | 33 checkout or a chromium checkout of PDFium.''' |
22 | 34 |
23 def __init__(self, build_location): | 35 def __init__(self, build_location): |
24 # |build_location| is typically "out/Debug" or "out/Release". | 36 # |build_location| is typically "out/Debug" or "out/Release". |
25 # Expect |my_dir| to be .../pdfium/testing/tools. | 37 # Expect |my_dir| to be .../pdfium/testing/tools. |
26 self.my_dir = os.path.dirname(os.path.realpath(__file__)) | 38 self.my_dir = os.path.dirname(os.path.realpath(__file__)) |
27 self.testing_dir = os.path.dirname(self.my_dir) | 39 self.testing_dir = os.path.dirname(self.my_dir) |
28 if (os.path.basename(self.my_dir) != 'tools' or | 40 if (os.path.basename(self.my_dir) != 'tools' or |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 if other_components: | 73 if other_components: |
62 result = os.path.join(result, other_components) | 74 result = os.path.join(result, other_components) |
63 return result | 75 return result |
64 | 76 |
65 def TestingDir(self, other_components=''): | 77 def TestingDir(self, other_components=''): |
66 '''Finds test files somewhere under the testing directory.''' | 78 '''Finds test files somewhere under the testing directory.''' |
67 result = self.testing_dir | 79 result = self.testing_dir |
68 if other_components: | 80 if other_components: |
69 result = os.path.join(result, other_components) | 81 result = os.path.join(result, other_components) |
70 return result | 82 return result |
OLD | NEW |