Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Generic utils.""" | 5 """Generic utils.""" |
| 6 | 6 |
| 7 import errno | 7 import errno |
| 8 import logging | 8 import logging |
| 9 import os | 9 import os |
| 10 import Queue | 10 import Queue |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 os.makedirs(tree) | 186 os.makedirs(tree) |
| 187 except OSError, e: | 187 except OSError, e: |
| 188 # 17 POSIX, 183 Windows | 188 # 17 POSIX, 183 Windows |
| 189 if e.errno not in (17, 183): | 189 if e.errno not in (17, 183): |
| 190 raise | 190 raise |
| 191 if count > 40: | 191 if count > 40: |
| 192 # Give up. | 192 # Give up. |
| 193 raise | 193 raise |
| 194 | 194 |
| 195 | 195 |
| 196 def FindCommandExecutable(cmd): | |
| 197 """Find the specified |cmd| in $PATH and checks if it's executable. | |
| 198 Raise an exception if fails. Otherwise do nothing.""" | |
| 199 paths = os.environ['PATH'].split(os.pathsep) | |
| 200 for path in paths: | |
|
M-A Ruel
2012/04/13 18:55:25
for path in os.environ['PATH'].split(os.pathsep):
Jun Mukai
2012/04/16 05:39:22
Done.
| |
| 201 full_path = os.path.join(path, cmd) | |
| 202 if os.path.isfile(full_path) and os.access(full_path, os.X_OK): | |
| 203 return full_path | |
| 204 return None | |
| 205 | |
| 206 | |
| 196 def CheckCallAndFilterAndHeader(args, always=False, **kwargs): | 207 def CheckCallAndFilterAndHeader(args, always=False, **kwargs): |
| 197 """Adds 'header' support to CheckCallAndFilter. | 208 """Adds 'header' support to CheckCallAndFilter. |
| 198 | 209 |
| 199 If |always| is True, a message indicating what is being done | 210 If |always| is True, a message indicating what is being done |
| 200 is printed to stdout all the time even if not output is generated. Otherwise | 211 is printed to stdout all the time even if not output is generated. Otherwise |
| 201 the message header is printed only if the call generated any ouput. | 212 the message header is printed only if the call generated any ouput. |
| 202 """ | 213 """ |
| 203 stdout = kwargs.get('stdout', None) or sys.stdout | 214 stdout = kwargs.get('stdout', None) or sys.stdout |
| 204 if always: | 215 if always: |
| 205 stdout.write('\n________ running \'%s\' in \'%s\'\n' | 216 stdout.write('\n________ running \'%s\' in \'%s\'\n' |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 766 keyvals = dict([x.strip() for x in l.split(':', 1)] for l in lines if l) | 777 keyvals = dict([x.strip() for x in l.split(':', 1)] for l in lines if l) |
| 767 except ValueError: | 778 except ValueError: |
| 768 raise Error( | 779 raise Error( |
| 769 'Failed to process settings, please fix. Content:\n\n%s' % content) | 780 'Failed to process settings, please fix. Content:\n\n%s' % content) |
| 770 def fix_url(key): | 781 def fix_url(key): |
| 771 if keyvals.get(key): | 782 if keyvals.get(key): |
| 772 keyvals[key] = UpgradeToHttps(keyvals[key]) | 783 keyvals[key] = UpgradeToHttps(keyvals[key]) |
| 773 fix_url('CODE_REVIEW_SERVER') | 784 fix_url('CODE_REVIEW_SERVER') |
| 774 fix_url('VIEW_VC') | 785 fix_url('VIEW_VC') |
| 775 return keyvals | 786 return keyvals |
| OLD | NEW |