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

Side by Side Diff: chrome/test/pyautolib/chromoting_helper.py

Issue 10821015: Initial checkin of the me2me pyauto automation: (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
Nirnimesh 2012/08/06 19:13:53 Docstring for this script please
yihongg 2012/08/08 01:04:48 Done.
5 import os
6 import sys
7 import subprocess
8
9
10 def _ReplacePrefPane(operation):
11 """Constructs mock pref pane to replace the actual pref pane."""
12 pref_pane_dir = os.path.join("/Library", "PreferencePanes")
Nirnimesh 2012/08/06 19:13:53 This applies to Mac only. Clearly call out so.
yihongg 2012/08/08 01:04:48 Done.
13
14 mock_pref_pane = os.path.join(pref_pane_dir, "mock_pref_pane")
15 pref_pane = os.path.join(pref_pane_dir, "org.chromium.chromoting.prefPane")
16 mock_pref_pane_python = os.path.join(os.getcwd(), "chrome", "test",
Nirnimesh 2012/08/06 19:13:53 chrome/test/pyautolib should not refer to chrome/t
yihongg 2012/08/08 01:04:48 This is to construct a bash script which contains
17 "functional", "chromoting",
18 "mock_pref_pane.py")
19
20 subprocess.call(["rm", "-rf", mock_pref_pane])
21
22 mock_pref_pane_file = open(mock_pref_pane, "w")
23 mock_pref_pane_file.write("#!/bin/bash\n")
24 mock_pref_pane_file.write("\n")
25 mock_pref_pane_file.write("suid-python" +
26 " " + mock_pref_pane_python + " " + operation)
27 mock_pref_pane_file.close()
28
29 subprocess.call(["chmod", "a+x", mock_pref_pane])
30 subprocess.call(["rm", "-rf", pref_pane])
31 subprocess.call(["ln", "-s", mock_pref_pane, pref_pane])
32
33
34 def main():
Nirnimesh 2012/08/06 19:13:53 main() -> Main() main is unusually long. Please r
yihongg 2012/08/08 01:04:48 Put the majority code in ChromotingHelper and used
35 """Chromoting helper script to install/uninstall/enable/disable host."""
Nirnimesh 2012/08/06 19:13:53 on all platforms?
yihongg 2012/08/08 01:04:48 Currently mainly mac and windows. install/uninstal
36 if sys.argv[1] == "install":
Nirnimesh 2012/08/06 19:13:53 The flow is too difficult to follow. Please refer
yihongg 2012/08/08 01:04:48 Done.
37 if sys.platform.startswith("win"):
38 host_msi = os.path.join(sys.argv[2], "remoting-host.msi")
39 subprocess.Popen(["msiexec", "/i", host_msi, "/passive"]).wait()
40 elif sys.platform.startswith('darwin'):
41 assert os.geteuid() == 0, 'Need superuser privileges'
42
43 # Run most of the steps here with login user
44 login_uid = os.getuid()
45 os.seteuid(login_uid)
46
47 # Change the working dir to the dir that has the host zip file
48 current_dir = os.getcwd()
49 bin_dir = sys.argv[2]
50 os.chdir(bin_dir)
51 host_dir = "remoting-me2me-host-mac"
52 output_dir = os.path.join(host_dir, "output")
53
54 # Remove remoting-me2me-host-mac dir just in case
55 subprocess.call("rm -f -R " + host_dir, shell=True)
56
57 # Unzip the host archive and prepare the files/dirs
58 subprocess.call("unzip remoting-me2me-host-mac.zip", shell=True)
59 subprocess.call("mkdir " + output_dir, shell=True)
60
61 # Prepare security identity for code signing purpose
62 os.seteuid(0)
63 key_chain = "/Library/Keychains/ChromotingTest"
64 password = "1111"
65 chromoting_test_dir = os.path.join(current_dir, "chrome", "test",
66 "functional", "chromoting")
67 key = os.path.join(chromoting_test_dir, "chromoting_key.p12")
68 cert = os.path.join(chromoting_test_dir, "chromoting_cert.p12")
69 subprocess.call(["security", "delete-keychain", key_chain])
70 subprocess.call(["security", "create-keychain", "-p",
71 password, key_chain])
72 subprocess.call(["security", "import", key,
73 "-k", key_chain, "-P", password, "-A"])
74 subprocess.call(["security", "import", cert,
75 "-k", key_chain, "-P", password])
76 os.seteuid(login_uid)
77
78 # Sign the host
79 do_signing = os.path.join(host_dir, "do_signing.sh")
80 subprocess.call(do_signing + " " + output_dir + " " + host_dir + " " +
81 key_chain + " \"Chromoting Test\"", shell=True)
82
83 # Remove security identify
84 os.seteuid(0)
85 subprocess.call(["security", "delete-keychain", key_chain])
86 os.seteuid(login_uid)
87
88 # Figure out the dmg name
89 version = ""
90 for output_file in os.listdir(output_dir):
91 if output_file.endswith(".dmg"):
92 version = os.path.basename(output_file)[len("ChromotingHost-"):-4]
93
94 # Mount before installation
95 dmg = os.path.join(output_dir, "ChromotingHost-" + version + ".dmg")
96 subprocess.call("hdiutil" + " mount " + dmg, shell=True)
97
98 # Install host
99 os.seteuid(0)
100 mpkg = os.path.join("/Volumes", "Chromoting Host " + version,
101 "Chromoting Host.mpkg")
102 subprocess.call(["/usr/sbin/installer", "-pkg",
103 mpkg, "-target", "/"])
104 os.seteuid(login_uid)
105
106 # Unmount after installation
107 mounted = os.path.join("/Volumes", "Chromoting Host " + version)
108 subprocess.call("hdiutil unmount \"" + mounted + "\"", shell=True)
109
110 # Clean up remoting-me2me-host-mac dir
111 subprocess.call("rm -f -R " + host_dir, shell=True)
112
113 # Resume the original working dir
114 os.chdir(current_dir)
115 else:
116 print("Nothing to be done for install")
117 elif sys.argv[1] == "uninstall":
118 if sys.platform.startswith("win"):
119 host_msi = os.path.join(sys.argv[2], "remoting-host.msi")
120 subprocess.Popen(["msiexec", "/x", host_msi, "/passive"]).wait()
121 elif sys.platform.startswith('darwin'):
122 assert os.geteuid() == 0, 'Need superuser privileges'
123 uninstall_app = os.path.join("/", "Applications",
124 "Chromoting Host Uninstaller.app")
125 subprocess.call(["open", "-a", uninstall_app])
126 else:
127 print("Nothing to be done for uninstall")
128 elif sys.argv[1] in ["enable", "disable", "changepin"]:
129 if sys.platform.startswith("darwin"):
130 assert os.geteuid() == 0, 'Need superuser privileges'
131 _ReplacePrefPane(sys.argv[1])
132 else:
133 print("Nothing to be done for enable")
Nirnimesh 2012/08/06 19:13:53 remove parens use ' instead of " throughout this f
yihongg 2012/08/08 01:04:48 Done.
134 else:
135 print >> sys.stderr, (
Nirnimesh 2012/08/06 19:13:53 remove space after >>
Nirnimesh 2012/08/06 19:13:53 remove parens
yihongg 2012/08/08 01:04:48 Done.
yihongg 2012/08/08 01:04:48 Done.
yihongg 2012/08/08 01:04:48 Done.
yihongg 2012/08/08 01:04:48 Done.
yihongg 2012/08/08 01:04:48 Done.
136 "Invalid syntax")
Nirnimesh 2012/08/06 19:13:53 move to previous line
yihongg 2012/08/08 01:04:48 Done.
137 return 1
138 return 0
139
140
141 if __name__ == '__main__':
142 sys.exit(main())
OLDNEW
« chrome/test/pyautolib/chromoting.py ('K') | « chrome/test/pyautolib/chromoting.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698