Add persisted preference for projection touch HUD
[chromium-blink-merge.git] / remoting / tools / keygen.py
blobd7e5d582c872150b2b6b05e787e5f92843eeb8dc
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import os
6 import sys
8 _SCRIPT_PATH = os.path.dirname(sys.argv[0])
9 if _SCRIPT_PATH == "":
10 _SCRIPT_PATH = os.getcwd()
12 _EXE_PATHS_TO_TRY = [
13 '.',
14 '..\\..\\build\\Debug',
15 '..\\..\\build\\Release',
16 '..\\Debug',
17 '..\\Release',
18 '../../xcodebuild/Debug',
19 '../../xcodebuild/Release',
20 '../../out/Debug',
21 '../../out/Release',
22 '/usr/lib/chrome-remote-desktop']
25 def locate_executable(exe_name):
26 for path in _EXE_PATHS_TO_TRY:
27 exe_path = os.path.join(_SCRIPT_PATH, path, exe_name)
28 if os.path.exists(exe_path):
29 return exe_path
30 exe_path = exe_path + ".exe"
31 if os.path.exists(exe_path):
32 return exe_path
34 raise Exception("Could not locate executable '%s'" % exe_name)
37 def generateRSAKeyPair():
38 """Returns (priv, pub) keypair where priv is a new private key and
39 pub is the corresponding public key. Both keys are BASE64 encoded."""
40 keygen_path = locate_executable("remoting_host_keygen")
41 pipe = os.popen(keygen_path)
42 out = pipe.readlines()
43 if len(out) != 2:
44 raise Exception("remoting_host_keygen failed.")
45 return (out[0].strip(), out[1].strip())