| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 def interpreter_for_script(script_path, fs=None): | 123 def interpreter_for_script(script_path, fs=None): |
| 124 fs = fs or FileSystem() | 124 fs = fs or FileSystem() |
| 125 lines = fs.read_text_file(script_path).splitlines() | 125 lines = fs.read_text_file(script_path).splitlines() |
| 126 if not len(lines): | 126 if not len(lines): |
| 127 return None | 127 return None |
| 128 first_line = lines[0] | 128 first_line = lines[0] |
| 129 if not first_line.startswith('#!'): | 129 if not first_line.startswith('#!'): |
| 130 return None | 130 return None |
| 131 if first_line.find('python') > -1: | 131 if first_line.find('python') > -1: |
| 132 return sys.executable | 132 return sys.executable |
| 133 if first_line.find('perl') > -1: | |
| 134 return 'perl' | |
| 135 if first_line.find('ruby') > -1: | 133 if first_line.find('ruby') > -1: |
| 136 return 'ruby' | 134 return 'ruby' |
| 137 return None | 135 return None |
| 138 | 136 |
| 139 @staticmethod | 137 @staticmethod |
| 140 def shell_command_for_script(script_path, fs=None): | 138 def shell_command_for_script(script_path, fs=None): |
| 141 fs = fs or FileSystem() | 139 fs = fs or FileSystem() |
| 142 # Win32 does not support shebang. We need to detect the interpreter ours
elf. | 140 # Win32 does not support shebang. We need to detect the interpreter ours
elf. |
| 143 if sys.platform == 'win32': | 141 if sys.platform == 'win32': |
| 144 interpreter = Executive.interpreter_for_script(script_path, fs) | 142 interpreter = Executive.interpreter_for_script(script_path, fs) |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 pool.close() | 452 pool.close() |
| 455 pool.join() | 453 pool.join() |
| 456 | 454 |
| 457 | 455 |
| 458 def _run_command_thunk(cmd_line_and_cwd): | 456 def _run_command_thunk(cmd_line_and_cwd): |
| 459 # Note that this needs to be a bare module (and hence Picklable) method to w
ork with multiprocessing.Pool. | 457 # Note that this needs to be a bare module (and hence Picklable) method to w
ork with multiprocessing.Pool. |
| 460 (cmd_line, cwd) = cmd_line_and_cwd | 458 (cmd_line, cwd) = cmd_line_and_cwd |
| 461 proc = subprocess.Popen(cmd_line, cwd=cwd, stdout=subprocess.PIPE, stderr=su
bprocess.PIPE) | 459 proc = subprocess.Popen(cmd_line, cwd=cwd, stdout=subprocess.PIPE, stderr=su
bprocess.PIPE) |
| 462 stdout, stderr = proc.communicate() | 460 stdout, stderr = proc.communicate() |
| 463 return (proc.returncode, stdout, stderr) | 461 return (proc.returncode, stdout, stderr) |
| OLD | NEW |