| OLD | NEW |
| 1 # Copyright (c) 2009, Google Inc. All rights reserved. | 1 # Copyright (c) 2009, Google Inc. All rights reserved. |
| 2 # Copyright (c) 2009 Apple Inc. All rights reserved. | 2 # Copyright (c) 2009 Apple Inc. All rights reserved. |
| 3 # | 3 # |
| 4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
| 5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
| 6 # met: | 6 # met: |
| 7 # | 7 # |
| 8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
| 9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
| 10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 fs = fs or FileSystem() | 119 fs = fs or FileSystem() |
| 120 # Win32 does not support shebang. We need to detect the interpreter ours
elf. | 120 # Win32 does not support shebang. We need to detect the interpreter ours
elf. |
| 121 if sys.platform == 'win32': | 121 if sys.platform == 'win32': |
| 122 interpreter = Executive.interpreter_for_script(script_path, fs) | 122 interpreter = Executive.interpreter_for_script(script_path, fs) |
| 123 if interpreter: | 123 if interpreter: |
| 124 return [interpreter, script_path] | 124 return [interpreter, script_path] |
| 125 return [script_path] | 125 return [script_path] |
| 126 | 126 |
| 127 def kill_process(self, pid): | 127 def kill_process(self, pid): |
| 128 """Attempts to kill the given pid. | 128 """Attempts to kill the given pid. |
| 129 Will fail silently if pid does not exist or insufficient permissions.""" | 129 Will fail silently if pid does not exist or insufficient permissions. |
| 130 """ |
| 130 if sys.platform == "win32": | 131 if sys.platform == "win32": |
| 131 # We only use taskkill.exe on windows (not cygwin) because subproces
s.pid | 132 # We only use taskkill.exe on windows (not cygwin) because subproces
s.pid |
| 132 # is a CYGWIN pid and taskkill.exe expects a windows pid. | 133 # is a CYGWIN pid and taskkill.exe expects a windows pid. |
| 133 # Thankfully os.kill on CYGWIN handles either pid type. | 134 # Thankfully os.kill on CYGWIN handles either pid type. |
| 134 command = ["taskkill.exe", "/f", "/t", "/pid", pid] | 135 command = ["taskkill.exe", "/f", "/t", "/pid", pid] |
| 135 # taskkill will exit 128 if the process is not found. We should log
. | 136 # taskkill will exit 128 if the process is not found. We should log
. |
| 136 self.run_command(command, error_handler=self.ignore_error) | 137 self.run_command(command, error_handler=self.ignore_error) |
| 137 return | 138 return |
| 138 | 139 |
| 139 # According to http://docs.python.org/library/os.html | 140 # According to http://docs.python.org/library/os.html |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 # http://bugs.python.org/issue5290 | 326 # http://bugs.python.org/issue5290 |
| 326 # See https://bugs.webkit.org/show_bug.cgi?id=37528 | 327 # See https://bugs.webkit.org/show_bug.cgi?id=37528 |
| 327 # for an example of a regression caused by passing a unicode string dire
ctly. | 328 # for an example of a regression caused by passing a unicode string dire
ctly. |
| 328 # FIXME: We may need to encode differently on different platforms. | 329 # FIXME: We may need to encode differently on different platforms. |
| 329 if isinstance(input, unicode): | 330 if isinstance(input, unicode): |
| 330 input = input.encode(self._child_process_encoding()) | 331 input = input.encode(self._child_process_encoding()) |
| 331 return (self.PIPE, input) | 332 return (self.PIPE, input) |
| 332 | 333 |
| 333 def command_for_printing(self, args): | 334 def command_for_printing(self, args): |
| 334 """Returns a print-ready string representing command args. | 335 """Returns a print-ready string representing command args. |
| 335 The string should be copy/paste ready for execution in a shell.""" | 336 The string should be copy/paste ready for execution in a shell. |
| 337 """ |
| 336 args = self._stringify_args(args) | 338 args = self._stringify_args(args) |
| 337 escaped_args = [] | 339 escaped_args = [] |
| 338 for arg in args: | 340 for arg in args: |
| 339 if isinstance(arg, unicode): | 341 if isinstance(arg, unicode): |
| 340 # Escape any non-ascii characters for easy copy/paste | 342 # Escape any non-ascii characters for easy copy/paste |
| 341 arg = arg.encode("unicode_escape") | 343 arg = arg.encode("unicode_escape") |
| 342 # FIXME: Do we need to fix quotes here? | 344 # FIXME: Do we need to fix quotes here? |
| 343 escaped_args.append(arg) | 345 escaped_args.append(arg) |
| 344 return " ".join(escaped_args) | 346 return " ".join(escaped_args) |
| 345 | 347 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 pool.close() | 459 pool.close() |
| 458 pool.join() | 460 pool.join() |
| 459 | 461 |
| 460 | 462 |
| 461 def _run_command_thunk(cmd_line_and_cwd): | 463 def _run_command_thunk(cmd_line_and_cwd): |
| 462 # Note that this needs to be a bare module (and hence Picklable) method to w
ork with multiprocessing.Pool. | 464 # Note that this needs to be a bare module (and hence Picklable) method to w
ork with multiprocessing.Pool. |
| 463 (cmd_line, cwd) = cmd_line_and_cwd | 465 (cmd_line, cwd) = cmd_line_and_cwd |
| 464 proc = subprocess.Popen(cmd_line, cwd=cwd, stdout=subprocess.PIPE, stderr=su
bprocess.PIPE) | 466 proc = subprocess.Popen(cmd_line, cwd=cwd, stdout=subprocess.PIPE, stderr=su
bprocess.PIPE) |
| 465 stdout, stderr = proc.communicate() | 467 stdout, stderr = proc.communicate() |
| 466 return (proc.returncode, stdout, stderr) | 468 return (proc.returncode, stdout, stderr) |
| OLD | NEW |