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