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 25 matching lines...) Expand all Loading... | |
36 import subprocess | 36 import subprocess |
37 import sys | 37 import sys |
38 import time | 38 import time |
39 | 39 |
40 from webkitpy.common.system.outputtee import Tee | 40 from webkitpy.common.system.outputtee import Tee |
41 from webkitpy.common.system.filesystem import FileSystem | 41 from webkitpy.common.system.filesystem import FileSystem |
42 | 42 |
43 | 43 |
44 _log = logging.getLogger(__name__) | 44 _log = logging.getLogger(__name__) |
45 | 45 |
46 class EnvPath(list): | |
47 """EnvPath represents a system environment PATH. It can be used for all | |
48 environment variables which are PATH-like, such as PYTHONPATH. The paths | |
49 are represented as a simple python list and live in memory until update() | |
50 is called at which point the environment variable gets written to. | |
51 """ | |
52 | |
53 def __init__(self, env, var, pathsep): | |
54 self._env = env | |
55 self._pathsep = pathsep | |
56 self._var = var | |
57 super(EnvPath, self).__init__(self._env[self._var].split(self._pathsep)) | |
58 | |
59 def update(self): | |
60 self._env[self._var] = self._pathsep.join(self) | |
Dirk Pranke
2015/06/12 22:25:01
These changes are not necessary, and we should nev
burnik
2015/06/15 10:35:09
Done.
| |
61 | |
46 | 62 |
47 class ScriptError(Exception): | 63 class ScriptError(Exception): |
48 | 64 |
49 def __init__(self, | 65 def __init__(self, |
50 message=None, | 66 message=None, |
51 script_args=None, | 67 script_args=None, |
52 exit_code=None, | 68 exit_code=None, |
53 output=None, | 69 output=None, |
54 cwd=None, | 70 cwd=None, |
55 output_limit=500): | 71 output_limit=500): |
(...skipping 23 matching lines...) Expand all Loading... | |
79 def command_name(self): | 95 def command_name(self): |
80 command_path = self.script_args | 96 command_path = self.script_args |
81 if type(command_path) is list: | 97 if type(command_path) is list: |
82 command_path = command_path[0] | 98 command_path = command_path[0] |
83 return os.path.basename(command_path) | 99 return os.path.basename(command_path) |
84 | 100 |
85 | 101 |
86 class Executive(object): | 102 class Executive(object): |
87 PIPE = subprocess.PIPE | 103 PIPE = subprocess.PIPE |
88 STDOUT = subprocess.STDOUT | 104 STDOUT = subprocess.STDOUT |
105 DEVNULL = open(os.devnull, 'wb') | |
106 pythonpath = EnvPath(os.environ, "PYTHONPATH", os.pathsep) | |
Dirk Pranke
2015/06/12 22:25:01
the pythonpath change isn't necessary.
burnik
2015/06/15 10:35:09
Done.
| |
89 | 107 |
90 def _should_close_fds(self): | 108 def _should_close_fds(self): |
91 # We need to pass close_fds=True to work around Python bug #2320 | 109 # We need to pass close_fds=True to work around Python bug #2320 |
92 # (otherwise we can hang when we kill DumpRenderTree when we are running | 110 # (otherwise we can hang when we kill DumpRenderTree when we are running |
93 # multiple threads). See http://bugs.python.org/issue2320 . | 111 # multiple threads). See http://bugs.python.org/issue2320 . |
94 # Note that close_fds isn't supported on Windows, but this bug only | 112 # Note that close_fds isn't supported on Windows, but this bug only |
95 # shows up on Mac and Linux. | 113 # shows up on Mac and Linux. |
96 return sys.platform not in ('win32', 'cygwin') | 114 return sys.platform not in ('win32', 'cygwin') |
97 | 115 |
98 def _run_command_with_teed_output(self, args, teed_output, **kwargs): | 116 def _run_command_with_teed_output(self, args, teed_output, **kwargs): |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
453 pool.close() | 471 pool.close() |
454 pool.join() | 472 pool.join() |
455 | 473 |
456 | 474 |
457 def _run_command_thunk(cmd_line_and_cwd): | 475 def _run_command_thunk(cmd_line_and_cwd): |
458 # Note that this needs to be a bare module (and hence Picklable) method to w ork with multiprocessing.Pool. | 476 # Note that this needs to be a bare module (and hence Picklable) method to w ork with multiprocessing.Pool. |
459 (cmd_line, cwd) = cmd_line_and_cwd | 477 (cmd_line, cwd) = cmd_line_and_cwd |
460 proc = subprocess.Popen(cmd_line, cwd=cwd, stdout=subprocess.PIPE, stderr=su bprocess.PIPE) | 478 proc = subprocess.Popen(cmd_line, cwd=cwd, stdout=subprocess.PIPE, stderr=su bprocess.PIPE) |
461 stdout, stderr = proc.communicate() | 479 stdout, stderr = proc.communicate() |
462 return (proc.returncode, stdout, stderr) | 480 return (proc.returncode, stdout, stderr) |
OLD | NEW |