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

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

Issue 23814002: Remove psutil from the mini_installer test framework. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove psutil from process_verifier.py. Created 7 years, 4 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 | chrome/test/mini_installer/process_verifier.py » ('j') | 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 00e892ab040957417846f4cf6bea6fc784488efc..776365c73da5ede2d7e80379e00bf12e7b6c053d 100644
--- a/chrome/test/mini_installer/chrome_helper.py
+++ b/chrome/test/mini_installer/chrome_helper.py
@@ -4,14 +4,34 @@
"""Common helper module for working with Chrome's processes and windows."""
-import psutil
+import ctypes
+import pywintypes
import re
+import win32con
import win32gui
import win32process
import path_resolver
+def GetProcessIDAndPathPairs():
+ """Returns a list of 2-tuples of (process id, process path)."""
gab 2013/08/30 16:20:21 Nice work; perhaps add a comment here saying that
sukolsak 2013/08/30 19:03:36 Done. psutil is available on Python 2.6, but it's
+ 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
+ try:
+ process_path = win32process.GetModuleFileNameEx(process_handle, 0)
+ process_id_and_path_pairs.append((process_id, process_path))
+ except pywintypes.error:
+ # It's normal that some processes are not accessible.
+ pass
+ return process_id_and_path_pairs
+
+
def GetProcessIDs(process_path):
"""Returns a list of IDs of processes whose path is |process_path|.
@@ -22,14 +42,9 @@ def GetProcessIDs(process_path):
A list of process IDs.
"""
process_ids = []
- for process in psutil.process_iter():
- try:
- found_process_path = process.exe
- if found_process_path == process_path:
- process_ids.append(process.pid)
- except psutil.AccessDenied:
- # It's normal that some processes are not accessible.
- pass
+ for found_process_id, found_process_path in GetProcessIDAndPathPairs():
+ if found_process_path == process_path:
+ process_ids.append(found_process_id)
return process_ids
« no previous file with comments | « no previous file | chrome/test/mini_installer/process_verifier.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698