OLD | NEW |
| (Empty) |
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 import getpass | |
7 import os | |
8 import re | |
9 import sys | |
10 import urllib | |
11 | |
12 | |
13 def usage(): | |
14 print('Usage: set_lkgr.py revision [git_hash [url]]') | |
15 sys.exit(1) | |
16 | |
17 | |
18 def get_pwd(): | |
19 if os.path.isfile('.status_password'): | |
20 return open('.status_password', 'r').read().strip() | |
21 return getpass.getpass() | |
22 | |
23 | |
24 def post(revision, git_hash='', url='chromium-status.appspot.com'): | |
25 if not re.match('^([a-zA-Z0-9]{40})?$', git_hash): | |
26 print 'Git hash must match /^([a-zA-Z0-9]{40})?$/.' | |
27 usage() | |
28 if not url.startswith('https://') and not url.startswith('http://'): | |
29 url = 'https://' + url | |
30 if url.startswith('http://'): | |
31 print('WARNING: Using set_lkgr.py with an http:// url only works on ' | |
32 'the dev_appserver.') | |
33 if raw_input('Continue (y/N): ').lower() != 'y': | |
34 print 'Aborting.' | |
35 sys.exit(1) | |
36 data = { | |
37 'revision': revision, | |
38 'success': 1, | |
39 'git_hash': git_hash, | |
40 'password': get_pwd(), | |
41 } | |
42 print url | |
43 out = urllib.urlopen(url + '/revisions', urllib.urlencode(data)).read() | |
44 print out | |
45 return 0 | |
46 | |
47 | |
48 if __name__ == '__main__': | |
49 if not (2 <= len(sys.argv) <= 4): | |
50 usage() | |
51 | |
52 sys.exit(post(*sys.argv[1:])) | |
OLD | NEW |