summaryrefslogtreecommitdiffstats
path: root/remoting/tools
diff options
context:
space:
mode:
authorlambroslambrou@google.com <lambroslambrou@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-10 23:19:43 +0000
committerlambroslambrou@google.com <lambroslambrou@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-10 23:19:43 +0000
commit627bb764d27288229c362c2087fedede41710bf2 (patch)
treeb8c49d53ccf428dfe0ffc8508e00085b3ab3613e /remoting/tools
parente4f373ea76ab139f690cf6b631e7e3b96ad0b7b8 (diff)
downloadchromium_src-627bb764d27288229c362c2087fedede41710bf2.zip
chromium_src-627bb764d27288229c362c2087fedede41710bf2.tar.gz
chromium_src-627bb764d27288229c362c2087fedede41710bf2.tar.bz2
Fix executable searching in keygen.py
Add the script's directory to the search path, so it can be used in a standalone tarball for Virtual Me2Me. Use os.path.join() instead of string concatenation. Make the module safe to import (that is, don't search for remoting_host_keygen whilst the module is being imported, because it fails to work from tools such as pychecker etc). BUG=None TEST=Manual Review URL: http://codereview.chromium.org/9114045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117104 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/tools')
-rw-r--r--remoting/tools/keygen.py55
1 files changed, 30 insertions, 25 deletions
diff --git a/remoting/tools/keygen.py b/remoting/tools/keygen.py
index deaeae1..482aeca 100644
--- a/remoting/tools/keygen.py
+++ b/remoting/tools/keygen.py
@@ -1,38 +1,43 @@
-# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Copyright (c) 2012 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
import sys
-SCRIPT_PATH = os.path.dirname(sys.argv[0])
-if SCRIPT_PATH == "":
- SCRIPT_PATH = os.getcwd()
-
-PATHS_TO_TRY = [
- '\\..\\..\\build\\Debug\\remoting_host_keygen.exe',
- '\\..\\..\\build\\Release\\remoting_host_keygen.exe',
- '\\..\\Debug\\remoting_host_keygen.exe',
- '\\..\\Release\\remoting_host_keygen.exe',
- '/../../xcodebuild/Debug/remoting_host_keygen',
- '/../../xcodebuild/Release/remoting_host_keygen',
- '/../../out/Debug/remoting_host_keygen',
- '/../../out/Release/remoting_host_keygen']
-
-KEYGEN_PATH = None
-for path in PATHS_TO_TRY:
- if os.path.exists(SCRIPT_PATH + path):
- KEYGEN_PATH = SCRIPT_PATH + path
- break
-
-if not KEYGEN_PATH:
- raise Exception("Unable to find remoting_host_keygen. Please build it " +
- "and try again")
+_SCRIPT_PATH = os.path.dirname(sys.argv[0])
+if _SCRIPT_PATH == "":
+ _SCRIPT_PATH = os.getcwd()
+
+_EXE_PATHS_TO_TRY = [
+ '.',
+ '..\\..\\build\\Debug',
+ '..\\..\\build\\Release',
+ '..\\Debug',
+ '..\\Release',
+ '../../xcodebuild/Debug',
+ '../../xcodebuild/Release',
+ '../../out/Debug',
+ '../../out/Release']
+
+
+def locate_executable(exe_name):
+ for path in _EXE_PATHS_TO_TRY:
+ exe_path = os.path.join(_SCRIPT_PATH, path, exe_name)
+ if os.path.exists(exe_path):
+ return exe_path
+ exe_path = exe_path + ".exe"
+ if os.path.exists(exe_path):
+ return exe_path
+
+ raise Exception("Could not locate executable '%s'" % exe_name)
+
def generateRSAKeyPair():
"""Returns (priv, pub) keypair where priv is a new private key and
pub is the corresponding public key. Both keys are BASE64 encoded."""
- pipe = os.popen(KEYGEN_PATH)
+ keygen_path = locate_executable("remoting_host_keygen")
+ pipe = os.popen(keygen_path)
out = pipe.readlines()
if len(out) != 2:
raise Exception("remoting_host_keygen failed.")