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

Unified Diff: tools/telemetry/telemetry/core/platform/posix_platform_backend.py

Issue 331843007: Add support for IsApplicationRunning on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove 'win' from test Created 6 years, 6 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
Index: tools/telemetry/telemetry/core/platform/posix_platform_backend.py
diff --git a/tools/telemetry/telemetry/core/platform/posix_platform_backend.py b/tools/telemetry/telemetry/core/platform/posix_platform_backend.py
index 9a867fd040ed7dd69cccc52b779268b2c999119b..4990452600ee5462720c6c982f9014ca5e641c04 100644
--- a/tools/telemetry/telemetry/core/platform/posix_platform_backend.py
+++ b/tools/telemetry/telemetry/core/platform/posix_platform_backend.py
@@ -31,7 +31,7 @@ class PosixPlatformBackend(desktop_platform_backend.DesktopPlatformBackend):
Args:
columns: A list of require columns, e.g., ['pid', 'pss'].
- pid: If nont None, returns only the information of the process
+ pid: If not None, returns only the information of the process
with the pid.
"""
args = ['ps']
@@ -71,6 +71,12 @@ class PosixPlatformBackend(desktop_platform_backend.DesktopPlatformBackend):
def CanLaunchApplication(self, application):
return bool(distutils.spawn.find_executable(application))
+ def IsApplicationRunning(self, application):
+ ps_output = self._GetPsOutput(['command'])
+ application_re = re.compile(
+ '(.*%s|^)%s(\s|$)' % (os.path.sep, application))
+ return any(application_re.match(cmd) for cmd in ps_output)
+
def LaunchApplication(
self, application, parameters=None, elevate_privilege=False):
assert application, 'Must specify application to launch'

Powered by Google App Engine
This is Rietveld 408576698