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 """Watch for rietveld issues with the commit bit set but no activity.""" | |
6 | |
7 import datetime | |
8 import logging | |
9 import optparse | |
10 import os | |
11 import re | |
12 import sys | |
13 import time | |
14 | |
15 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
16 | |
17 import find_depot_tools # pylint: disable=W0611 | |
18 import breakpad | |
19 import rietveld | |
20 | |
21 | |
22 def seconds(td): | |
23 return td.seconds + td.days * 24 * 3600 | |
24 | |
25 | |
26 def to_epoch(date_str): | |
27 dt = datetime.datetime(*map(int, re.split('[^\d]', date_str)[:-1])) | |
28 return seconds(dt - datetime.datetime(1970, 1, 1)) | |
29 | |
30 | |
31 def main(): | |
32 parser = optparse.OptionParser( | |
33 description=sys.modules['__main__'].__doc__) | |
34 parser.add_option('-d', '--delay', default=3*60*60, type='int') | |
35 parser.add_option('-u', '--user') | |
36 parser.add_option('-v', '--verbose', action='store_true') | |
37 options, args = parser.parse_args(None) | |
38 if options.verbose: | |
39 logging.basicConfig(level=logging.DEBUG) | |
40 else: | |
41 logging.basicConfig(level=logging.ERROR) | |
42 if len(args) != 1: | |
43 parser.error('Need 1 arg') | |
44 | |
45 url = args[0].rstrip('/') + '/' | |
46 if not 'http' in url: | |
47 url = 'http://' + url | |
48 obj = rietveld.Rietveld(args[0], options.user, None) | |
49 notified = [] | |
50 while True: | |
51 now = time.time() | |
52 earliest = now - options.delay | |
53 for issue in obj.search(commit='1', closed='2'): | |
54 print '%d' % issue['issue'] | |
55 if issue['issue'] in notified: | |
56 continue | |
57 if (not issue['base_url'] or | |
58 to_epoch(issue['modified']) < earliest): | |
59 data = ['%s%d' % (url, issue['issue']), issue['base_url']] | |
60 breakpad.SendStack(str(now), data) | |
61 notified.append(issue['issue']) | |
62 time.sleep(5*60) | |
63 return 0 | |
64 | |
65 | |
66 if __name__ == '__main__': | |
67 sys.exit(main()) | |
OLD | NEW |