OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
3 # 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 |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 | 6 |
7 import getpass | 7 import getpass |
8 import os | 8 import os |
9 import re | 9 import re |
10 import subprocess | 10 import subprocess |
11 import sys | 11 import sys |
12 import tempfile | 12 import tempfile |
13 import urllib | 13 import urllib |
14 | 14 |
15 | 15 |
16 def Authenticate(): | 16 def Authenticate(): |
17 # Authenticate. | 17 default_username = getpass.getuser() |
18 default_username = os.environ.get('LOGNAME', '') | |
19 username = os.environ.get('GSDCURL_USERNAME') | 18 username = os.environ.get('GSDCURL_USERNAME') |
20 if username is None: | 19 if username is None: |
21 sys.stderr.write('Username [' + default_username + ']: ') | 20 sys.stderr.write('Username [' + default_username + ']: ') |
22 username = raw_input() | 21 username = raw_input() |
23 if username == '': | 22 if username == '': |
24 username = default_username + '@google.com' | 23 username = default_username + '@google.com' |
25 elif '@' not in username: | 24 elif '@' not in username: |
26 username = username + '@google.com' | 25 username = username + '@google.com' |
27 passwd = os.environ.get('GSDCURL_PASSWORD') | 26 passwd = os.environ.get('GSDCURL_PASSWORD') |
28 if passwd is None: | 27 if passwd is None: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 os.remove(cookies) | 60 os.remove(cookies) |
62 | 61 |
63 | 62 |
64 def main(argv): | 63 def main(argv): |
65 auth = Authenticate() | 64 auth = Authenticate() |
66 return DoCurl(auth, argv) | 65 return DoCurl(auth, argv) |
67 | 66 |
68 | 67 |
69 if __name__ == '__main__': | 68 if __name__ == '__main__': |
70 sys.exit(main(sys.argv)) | 69 sys.exit(main(sys.argv)) |
OLD | NEW |