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

Side by Side Diff: gclient_utils.py

Issue 2673002: Add pylintrc and fix style for many scripts. (Closed)
Patch Set: . Created 10 years, 6 months 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
« no previous file with comments | « gclient_scm.py ('k') | pylintrc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2009 Google Inc. All Rights Reserved. 1 # Copyright 2009 Google Inc. All Rights Reserved.
2 # 2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); 3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License. 4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at 5 # You may obtain a copy of the License at
6 # 6 #
7 # http://www.apache.org/licenses/LICENSE-2.0 7 # http://www.apache.org/licenses/LICENSE-2.0
8 # 8 #
9 # Unless required by applicable law or agreed to in writing, software 9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, 10 # distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 description. 221 description.
222 """ 222 """
223 # Call subprocess and capture nothing: 223 # Call subprocess and capture nothing:
224 SubprocessCallAndFilter(command, in_directory, True, True, fail_status) 224 SubprocessCallAndFilter(command, in_directory, True, True, fail_status)
225 225
226 226
227 def SubprocessCallAndFilter(command, 227 def SubprocessCallAndFilter(command,
228 in_directory, 228 in_directory,
229 print_messages, 229 print_messages,
230 print_stdout, 230 print_stdout,
231 fail_status=None, filter=None): 231 fail_status=None, filter_fn=None):
232 """Runs command, a list, in directory in_directory. 232 """Runs command, a list, in directory in_directory.
233 233
234 If print_messages is true, a message indicating what is being done 234 If print_messages is true, a message indicating what is being done
235 is printed to stdout. If print_messages is false, the message is printed 235 is printed to stdout. If print_messages is false, the message is printed
236 only if we actually need to print something else as well, so you can 236 only if we actually need to print something else as well, so you can
237 get the context of the output. If print_messages is false and print_stdout 237 get the context of the output. If print_messages is false and print_stdout
238 is false, no output at all is generated. 238 is false, no output at all is generated.
239 239
240 Also, if print_stdout is true, the command's stdout is also forwarded 240 Also, if print_stdout is true, the command's stdout is also forwarded
241 to stdout. 241 to stdout.
242 242
243 If a filter function is specified, it is expected to take a single 243 If a filter_fn function is specified, it is expected to take a single
244 string argument, and it will be called with each line of the 244 string argument, and it will be called with each line of the
245 subprocess's output. Each line has had the trailing newline character 245 subprocess's output. Each line has had the trailing newline character
246 trimmed. 246 trimmed.
247 247
248 If the command fails, as indicated by a nonzero exit status, gclient will 248 If the command fails, as indicated by a nonzero exit status, gclient will
249 exit with an exit status of fail_status. If fail_status is None (the 249 exit with an exit status of fail_status. If fail_status is None (the
250 default), gclient will raise an Error exception. 250 default), gclient will raise an Error exception.
251 """ 251 """
252 logging.debug(command) 252 logging.debug(command)
253 if print_messages: 253 if print_messages:
(...skipping 16 matching lines...) Expand all
270 while in_byte: 270 while in_byte:
271 if in_byte != "\r": 271 if in_byte != "\r":
272 if print_stdout: 272 if print_stdout:
273 if not print_messages: 273 if not print_messages:
274 print("\n________ running \'%s\' in \'%s\'" 274 print("\n________ running \'%s\' in \'%s\'"
275 % (' '.join(command), in_directory)) 275 % (' '.join(command), in_directory))
276 print_messages = True 276 print_messages = True
277 sys.stdout.write(in_byte) 277 sys.stdout.write(in_byte)
278 if in_byte != "\n": 278 if in_byte != "\n":
279 in_line += in_byte 279 in_line += in_byte
280 if in_byte == "\n" and filter: 280 if in_byte == "\n" and filter_fn:
281 filter(in_line) 281 filter_fn(in_line)
282 in_line = "" 282 in_line = ""
283 in_byte = kid.stdout.read(1) 283 in_byte = kid.stdout.read(1)
284 rv = kid.wait() 284 rv = kid.wait()
285 285
286 if rv: 286 if rv:
287 msg = "failed to run command: %s" % " ".join(command) 287 msg = "failed to run command: %s" % " ".join(command)
288 288
289 if fail_status != None: 289 if fail_status != None:
290 print >>sys.stderr, msg 290 print >>sys.stderr, msg
291 sys.exit(fail_status) 291 sys.exit(fail_status)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 config_path = FindFileUpwards(config_file, path) 346 config_path = FindFileUpwards(config_file, path)
347 347
348 if not config_path: 348 if not config_path:
349 print "Can't find", config_file 349 print "Can't find", config_file
350 return None 350 return None
351 351
352 env = {} 352 env = {}
353 execfile(config_path, env) 353 execfile(config_path, env)
354 config_dir = os.path.dirname(config_path) 354 config_dir = os.path.dirname(config_path)
355 return config_dir, env['entries'] 355 return config_dir, env['entries']
OLDNEW
« no previous file with comments | « gclient_scm.py ('k') | pylintrc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698