Commit 02247c02 authored by huangs's avatar huangs Committed by Commit bot

[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}
parent 3fca97f4
...@@ -4,32 +4,20 @@ ...@@ -4,32 +4,20 @@
"""Common helper module for working with Chrome's processes and windows.""" """Common helper module for working with Chrome's processes and windows."""
import ctypes import psutil
import pywintypes
import re import re
import win32con
import win32gui import win32gui
import win32process import win32process
def GetProcessIDAndPathPairs(): def GetProcessIDAndPathPairs():
"""Returns a list of 2-tuples of (process id, process path). """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 = [] process_id_and_path_pairs = []
for process_id in win32process.EnumProcesses(): for process in psutil.process_iter():
process_handle = ctypes.windll.kernel32.OpenProcess(
win32con.PROCESS_QUERY_INFORMATION | win32con.PROCESS_VM_READ, False,
process_id)
if not process_handle:
continue
try: try:
process_path = win32process.GetModuleFileNameEx(process_handle, 0) process_id_and_path_pairs.append((process.pid, process.exe))
process_id_and_path_pairs.append((process_id, process_path)) except psutil.Error:
except pywintypes.error:
# It's normal that some processes are not accessible. # It's normal that some processes are not accessible.
pass pass
return process_id_and_path_pairs return process_id_and_path_pairs
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment