OLD | NEW |
1 # Copyright (C) 2011 Google Inc. All rights reserved. | 1 # Copyright (C) 2011 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 def running_pids(self, process_name_filter): | 76 def running_pids(self, process_name_filter): |
77 running_pids = [] | 77 running_pids = [] |
78 for process_name, process_pid in self._running_pids.iteritems(): | 78 for process_name, process_pid in self._running_pids.iteritems(): |
79 if process_name_filter(process_name): | 79 if process_name_filter(process_name): |
80 running_pids.append(process_pid) | 80 running_pids.append(process_pid) |
81 | 81 |
82 _log.info("MOCK running_pids: %s" % running_pids) | 82 _log.info("MOCK running_pids: %s" % running_pids) |
83 return running_pids | 83 return running_pids |
84 | 84 |
85 def run_and_throw_if_fail(self, args, quiet=False, cwd=None, env=None): | |
86 self.calls.append(args) | |
87 if self._should_log: | |
88 env_string = "" | |
89 if env: | |
90 env_string = ", env=%s" % env | |
91 _log.info("MOCK run_and_throw_if_fail: %s, cwd=%s%s" % (args, cwd, e
nv_string)) | |
92 if self._should_throw_when_run.intersection(args): | |
93 raise ScriptError("Exception for %s" % args, output="MOCK command ou
tput") | |
94 return "MOCK output of child process" | |
95 | |
96 def command_for_printing(self, args): | 85 def command_for_printing(self, args): |
97 string_args = map(unicode, args) | 86 string_args = map(unicode, args) |
98 return " ".join(string_args) | 87 return " ".join(string_args) |
99 | 88 |
100 def run_command(self, | 89 def run_command(self, |
101 args, | 90 args, |
102 cwd=None, | 91 cwd=None, |
103 input=None, | 92 input=None, |
104 error_handler=None, | 93 error_handler=None, |
105 return_exit_code=False, | 94 return_exit_code=False, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 if self._run_command_fn: | 189 if self._run_command_fn: |
201 return self._run_command_fn(args) | 190 return self._run_command_fn(args) |
202 if return_exit_code: | 191 if return_exit_code: |
203 return self._exit_code | 192 return self._exit_code |
204 if self._exit_code and error_handler: | 193 if self._exit_code and error_handler: |
205 script_error = ScriptError(script_args=args, exit_code=self._exit_co
de, output=self._output) | 194 script_error = ScriptError(script_args=args, exit_code=self._exit_co
de, output=self._output) |
206 error_handler(script_error) | 195 error_handler(script_error) |
207 if return_stderr: | 196 if return_stderr: |
208 return self._output + self._stderr | 197 return self._output + self._stderr |
209 return self._output | 198 return self._output |
OLD | NEW |