Fix error in page cycler test with Web Page Replay.
[chromium-blink-merge.git] / remoting / tools / keygen.py
blob482aeca86f81b4595d3de6411492afca81dcda71
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']
24 def locate_executable(exe_name):
25 for path in _EXE_PATHS_TO_TRY:
26 exe_path = os.path.join(_SCRIPT_PATH, path, exe_name)
27 if os.path.exists(exe_path):
28 return exe_path
29 exe_path = exe_path + ".exe"
30 if os.path.exists(exe_path):
31 return exe_path
33 raise Exception("Could not locate executable '%s'" % exe_name)
36 def generateRSAKeyPair():
37 """Returns (priv, pub) keypair where priv is a new private key and
38 pub is the corresponding public key. Both keys are BASE64 encoded."""
39 keygen_path = locate_executable("remoting_host_keygen")
40 pipe = os.popen(keygen_path)
41 out = pipe.readlines()
42 if len(out) != 2:
43 raise Exception("remoting_host_keygen failed.")
44 return (out[0].strip(), out[1].strip())