OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
4 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 4 # found in the LICENSE file. |
6 # | 5 |
7 # runclient.py gets the chromoting host info from an input arg and then | 6 """Gets the chromoting host info from an input arg and then |
8 # tries to find the authentication info in the .chromotingAuthToken file | 7 tries to find the authentication info in the .chromotingAuthToken file |
9 # so that the host authentication arguments can be automatically set. | 8 so that the host authentication arguments can be automatically set. |
| 9 """ |
10 | 10 |
11 import os | 11 import os |
12 import platform | 12 import platform |
| 13 import sys |
13 | 14 |
14 auth_filepath = os.path.join(os.path.expanduser('~'), '.chromotingAuthToken') | 15 def main(): |
15 script_path = os.path.dirname(__file__) | 16 auth_filepath = os.path.join(os.path.expanduser('~'), '.chromotingAuthToken') |
| 17 script_path = os.path.dirname(__file__) |
16 | 18 |
17 if platform.system() == "Windows": | 19 if platform.system() == "Windows": |
18 # TODO(garykac): Make this work on Windows. | 20 # TODO(garykac): Make this work on Windows. |
19 print 'Not yet supported on Windows.' | 21 print 'Not yet supported on Windows.' |
20 exit(1) | 22 return 1 |
21 elif platform.system() == "Darwin": # Darwin == MacOSX | 23 elif platform.system() == "Darwin": # Darwin == MacOSX |
22 client_path = '../../xcodebuild/Debug/chromoting_simple_client' | 24 client_path = '../../xcodebuild/Debug/chromoting_simple_client' |
23 else: | 25 else: |
24 client_path = '../../out/Debug/chromoting_x11_client' | 26 client_path = '../../out/Debug/chromoting_x11_client' |
25 | 27 |
26 client_path = os.path.join(script_path, client_path) | 28 client_path = os.path.join(script_path, client_path) |
27 | 29 |
28 # Read username and auth token from token file. | 30 # Read username and auth token from token file. |
29 auth = open(auth_filepath) | 31 auth = open(auth_filepath) |
30 authinfo = auth.readlines() | 32 authinfo = auth.readlines() |
31 | 33 |
32 username = authinfo[0].rstrip() | 34 username = authinfo[0].rstrip() |
33 authtoken = authinfo[1].rstrip() | 35 authtoken = authinfo[1].rstrip() |
34 | 36 |
35 # Request final 8 characters of Host JID from user. | 37 # Request final 8 characters of Host JID from user. |
36 # This assumes that the host is published under the same username as the | 38 # This assumes that the host is published under the same username as the |
37 # client attempting to connect. | 39 # client attempting to connect. |
38 print 'Host JID:', username + '/chromoting', | 40 print 'Host JID:', username + '/chromoting', |
39 hostjid_suffix = raw_input() | 41 hostjid_suffix = raw_input() |
40 hostjid = username + '/chromoting' + hostjid_suffix.upper() | 42 hostjid = username + '/chromoting' + hostjid_suffix.upper() |
41 | 43 |
42 command = [] | 44 command = [] |
43 command.append(client_path) | 45 command.append(client_path) |
44 command.append('--host_jid ' + hostjid) | 46 command.append('--host_jid ' + hostjid) |
45 command.append('--jid ' + username) | 47 command.append('--jid ' + username) |
46 command.append('--token ' + authtoken) | 48 command.append('--token ' + authtoken) |
47 | 49 |
48 # Launch the client | 50 # Launch the client |
49 os.system(' '.join(command)) | 51 os.system(' '.join(command)) |
| 52 return 0 |
| 53 |
| 54 |
| 55 if __name__ == '__main__': |
| 56 sys.exit(main()) |
OLD | NEW |