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 """Finds the specified |cmd| in $PATH and returns its path. Returns None | |
198 if it's not found.""" | |
199 for path in os.environ['PATH'].split(os.pathsep): | |
200 full_path = os.path.join(path, cmd) | |
201 if os.path.isfile(full_path) and os.access(full_path, os.X_OK): | |
202 return full_path | |
203 return None | |
204 | |
205 | |
206 def CheckCallAndFilterAndHeader(args, always=False, **kwargs): | 196 def CheckCallAndFilterAndHeader(args, always=False, **kwargs): |
207 """Adds 'header' support to CheckCallAndFilter. | 197 """Adds 'header' support to CheckCallAndFilter. |
208 | 198 |
209 If |always| is True, a message indicating what is being done | 199 If |always| is True, a message indicating what is being done |
210 is printed to stdout all the time even if not output is generated. Otherwise | 200 is printed to stdout all the time even if not output is generated. Otherwise |
211 the message header is printed only if the call generated any ouput. | 201 the message header is printed only if the call generated any ouput. |
212 """ | 202 """ |
213 stdout = kwargs.get('stdout', None) or sys.stdout | 203 stdout = kwargs.get('stdout', None) or sys.stdout |
214 if always: | 204 if always: |
215 stdout.write('\n________ running \'%s\' in \'%s\'\n' | 205 stdout.write('\n________ running \'%s\' in \'%s\'\n' |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 keyvals = dict([x.strip() for x in l.split(':', 1)] for l in lines if l) | 766 keyvals = dict([x.strip() for x in l.split(':', 1)] for l in lines if l) |
777 except ValueError: | 767 except ValueError: |
778 raise Error( | 768 raise Error( |
779 'Failed to process settings, please fix. Content:\n\n%s' % content) | 769 'Failed to process settings, please fix. Content:\n\n%s' % content) |
780 def fix_url(key): | 770 def fix_url(key): |
781 if keyvals.get(key): | 771 if keyvals.get(key): |
782 keyvals[key] = UpgradeToHttps(keyvals[key]) | 772 keyvals[key] = UpgradeToHttps(keyvals[key]) |
783 fix_url('CODE_REVIEW_SERVER') | 773 fix_url('CODE_REVIEW_SERVER') |
784 fix_url('VIEW_VC') | 774 fix_url('VIEW_VC') |
785 return keyvals | 775 return keyvals |
OLD | NEW |