diff options
author | huangs <huangs@chromium.org> | 2014-09-12 13:39:59 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-12 20:42:49 +0000 |
commit | 02247c02b993b041e0da5a1f03e2f173ff81e888 (patch) | |
tree | bb4d31813b649e23a750482fa9f10d3b33798bed | |
parent | 3fca97f4ad235b7940949a3a53cfd8ca6835b110 (diff) | |
download | chromium_src-02247c02b993b041e0da5a1f03e2f173ff81e888.zip chromium_src-02247c02b993b041e0da5a1f03e2f173ff81e888.tar.gz chromium_src-02247c02b993b041e0da5a1f03e2f173ff81e888.tar.bz2 |
[Installer Test] Update chrome_helper.GetProcessIDAndPathPairs() to use psutil.
BUG=399643
Review URL: https://codereview.chromium.org/565963002
Cr-Commit-Position: refs/heads/master@{#294652}
-rw-r--r-- | chrome/test/mini_installer/chrome_helper.py | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/chrome/test/mini_installer/chrome_helper.py b/chrome/test/mini_installer/chrome_helper.py index a927835..1dcedba 100644 --- a/chrome/test/mini_installer/chrome_helper.py +++ b/chrome/test/mini_installer/chrome_helper.py @@ -4,32 +4,20 @@ """Common helper module for working with Chrome's processes and windows.""" -import ctypes -import pywintypes +import psutil import re -import win32con import win32gui import win32process def GetProcessIDAndPathPairs(): """Returns a list of 2-tuples of (process id, process path). - - This is needed because psutil is not available on Windows slave machines (see: - http://crbug.com/257696). - TODO(sukolsak): Use psutil.process_iter() once it becomes available. """ process_id_and_path_pairs = [] - for process_id in win32process.EnumProcesses(): - process_handle = ctypes.windll.kernel32.OpenProcess( - win32con.PROCESS_QUERY_INFORMATION | win32con.PROCESS_VM_READ, False, - process_id) - if not process_handle: - continue + for process in psutil.process_iter(): try: - process_path = win32process.GetModuleFileNameEx(process_handle, 0) - process_id_and_path_pairs.append((process_id, process_path)) - except pywintypes.error: + process_id_and_path_pairs.append((process.pid, process.exe)) + except psutil.Error: # It's normal that some processes are not accessible. pass return process_id_and_path_pairs |