| 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 if not process_name_filter: | 237 if not process_name_filter: |
| 238 process_name_filter = lambda process_name: True | 238 process_name_filter = lambda process_name: True |
| 239 | 239 |
| 240 running_pids = [] | 240 running_pids = [] |
| 241 for line in self._running_processes(): | 241 for line in self._running_processes(): |
| 242 try: | 242 try: |
| 243 process_name = line[0] | 243 process_name = line[0] |
| 244 pid = line[1] | 244 pid = line[1] |
| 245 if process_name_filter(process_name): | 245 if process_name_filter(process_name): |
| 246 running_pids.append(int(pid)) | 246 running_pids.append(int(pid)) |
| 247 except (ValueError, IndexError) as e: | 247 except (ValueError, IndexError): |
| 248 pass | 248 pass |
| 249 | 249 |
| 250 return sorted(running_pids) | 250 return sorted(running_pids) |
| 251 | 251 |
| 252 def process_dump(self): | 252 def process_dump(self): |
| 253 ps_process = None | 253 ps_process = None |
| 254 if sys.platform in ("win32", "cygwin"): | 254 if sys.platform in ("win32", "cygwin"): |
| 255 ps_process = self.popen( | 255 ps_process = self.popen( |
| 256 ['wmic', 'process', 'get', | 256 ['wmic', 'process', 'get', |
| 257 'ProcessId,ParentProcessId,CommandLine'], | 257 'ProcessId,ParentProcessId,CommandLine'], |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 pool.close() | 457 pool.close() |
| 458 pool.join() | 458 pool.join() |
| 459 | 459 |
| 460 | 460 |
| 461 def _run_command_thunk(cmd_line_and_cwd): | 461 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. | 462 # 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 | 463 (cmd_line, cwd) = cmd_line_and_cwd |
| 464 proc = subprocess.Popen(cmd_line, cwd=cwd, stdout=subprocess.PIPE, stderr=su
bprocess.PIPE) | 464 proc = subprocess.Popen(cmd_line, cwd=cwd, stdout=subprocess.PIPE, stderr=su
bprocess.PIPE) |
| 465 stdout, stderr = proc.communicate() | 465 stdout, stderr = proc.communicate() |
| 466 return (proc.returncode, stdout, stderr) | 466 return (proc.returncode, stdout, stderr) |
| OLD | NEW |