Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5472)

Unified Diff: chrome/test/mini_installer/chrome_helper.py

Issue 565963002: [Installer Test] Update chrome_helper.GetProcessIDAndPathPairs() to use psutil. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/mini_installer/chrome_helper.py
diff --git a/chrome/test/mini_installer/chrome_helper.py b/chrome/test/mini_installer/chrome_helper.py
index a9278355fb2675af1d5fe07bf427fa5a8dc207b4..a714b5a92d7dfee472a8cf96e7a2143bb1c12edc 100644
--- a/chrome/test/mini_installer/chrome_helper.py
+++ b/chrome/test/mini_installer/chrome_helper.py
@@ -5,6 +5,7 @@
"""Common helper module for working with Chrome's processes and windows."""
import ctypes
grt (UTC plus 2) 2014/09/12 15:01:11 unused
huangs 2014/09/12 18:25:33 Done.
+import psutil
import pywintypes
grt (UTC plus 2) 2014/09/12 15:01:11 unused
huangs 2014/09/12 18:25:33 Done.
import re
import win32con
grt (UTC plus 2) 2014/09/12 15:01:11 unused
huangs 2014/09/12 18:25:33 Done.
@@ -14,22 +15,12 @@ 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))
grt (UTC plus 2) 2014/09/12 15:01:11 http://pythonhosted.org/psutil/#psutil.Process say
grt (UTC plus 2) 2014/09/12 15:01:11 process.exe -> process.exe()
huangs 2014/09/12 18:25:33 Catching psutil.Error, per suggested below.
huangs 2014/09/12 18:25:33 From https://code.google.com/p/psutil/wiki/Documen
grt (UTC plus 2) 2014/09/12 18:35:20 Odd. http://pythonhosted.org/psutil/#psutil.Proces
+ except psutil._error.AccessDenied:
grt (UTC plus 2) 2014/09/12 15:01:11 perhaps just catch psutil.Error here, since that's
huangs 2014/09/12 18:25:33 Done.
# It's normal that some processes are not accessible.
pass
return process_id_and_path_pairs
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698