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

Unified Diff: tools/telemetry/telemetry/util/path.py

Issue 412553006: [telemetry] Add util.path module and util.path.FindInstalledWindowsApplication. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit test. Created 6 years, 5 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 | « tools/telemetry/telemetry/util/cloud_storage.py ('k') | tools/telemetry/telemetry/util/path_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/util/path.py
diff --git a/tools/telemetry/telemetry/util/path.py b/tools/telemetry/telemetry/util/path.py
new file mode 100644
index 0000000000000000000000000000000000000000..7feb861bdfba2c627cae5c062d998c5da32f7d29
--- /dev/null
+++ b/tools/telemetry/telemetry/util/path.py
@@ -0,0 +1,43 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+
+from telemetry.core import util
+
+
+# TODO(dtu): Move these functions from core.util to here.
+GetBaseDir = util.GetBaseDir
+GetTelemetryDir = util.GetTelemetryDir
+GetUnittestDataDir = util.GetUnittestDataDir
+GetChromiumSrcDir = util.GetChromiumSrcDir
+AddDirToPythonPath = util.AddDirToPythonPath
+GetBuildDirectories = util.GetBuildDirectories
+
+
+def IsExecutable(path):
+ return os.path.isfile(path) and os.access(path, os.X_OK)
+
+
+def FindInstalledWindowsApplication(application_path):
+ """Search common Windows installation directories for an application.
+
+ Args:
+ application_path: Path to application relative from installation location.
+ Returns:
+ A string representing the full path, or None if not found.
+ """
+ search_paths = [os.getenv('PROGRAMFILES(X86)'),
+ os.getenv('PROGRAMFILES'),
+ os.getenv('LOCALAPPDATA')]
+ search_paths += os.getenv('PATH', '').split(os.pathsep)
+
+ for search_path in search_paths:
+ if not search_path:
+ continue
+ path = os.path.join(search_path, application_path)
+ if IsExecutable(path):
+ return path
+
+ return None
« no previous file with comments | « tools/telemetry/telemetry/util/cloud_storage.py ('k') | tools/telemetry/telemetry/util/path_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698