Enable Enterprise enrollment on desktop builds.
[chromium-blink-merge.git] / chrome / common / extensions / docs / server2 / update_server.py
blob9df8932d130ee281e09cdd09f0f2741073a662e0
1 #!/usr/bin/env python
2 # Copyright (c) 2012 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.
6 import getpass
7 import os
8 import subprocess
9 import sys
11 import build_server
13 if __name__ == '__main__':
14 additional_args = []
15 if len(sys.argv) > 1 and sys.argv[1].endswith('appcfg.py'):
16 appcfg_path = sys.argv[1]
17 additional_args = sys.argv[2:]
18 else:
19 appcfg_path = None
20 additional_args = sys.argv[1:]
21 for path in ['.',
22 os.path.join(os.environ['HOME'], 'local', 'google_appengine'),
23 os.path.join(os.environ['HOME'], 'google_appengine'),
24 os.getcwd()] + sys.path:
25 full_path = os.path.join(path, 'appcfg.py')
26 if os.path.exists(full_path):
27 appcfg_path = full_path
28 break
29 if appcfg_path is None:
30 print 'appcfg.py could not be found in default paths.'
31 print 'usage: update_server.py <path_to_appcfg.py> <appcfg_options>'
32 exit(1)
34 def run_appcfg():
35 server2_path = os.path.dirname(sys.argv[0])
36 subprocess.call([appcfg_path, 'update', server2_path] + additional_args)
38 build_server.main()
39 username = raw_input(
40 'Update github username/password (empty to skip)? ')
41 if username:
42 password = getpass.getpass()
43 with open('github_file_system.py') as f:
44 contents = f.read()
45 if 'USERNAME = None' not in contents:
46 print 'Error: Can\'t find "USERNAME = None" in github_file_system.py.'
47 exit(1)
48 if 'PASSWORD = None' not in contents:
49 print 'Error: Can\'t find "PASSWORD = None" in github_file_system.py.'
50 exit(1)
51 try:
52 with open('github_file_system.py', 'w+') as f:
53 f.write(
54 contents.replace('PASSWORD = None', 'PASSWORD = \'%s\'' % password)
55 .replace('USERNAME = None', 'USERNAME = \'%s\'' % username))
56 run_appcfg()
57 finally:
58 with open('github_file_system.py', 'w+') as f:
59 f.write(contents)
60 else:
61 run_appcfg()