Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: commit-queue/verification/tree_status.py

Issue 59693004: CQ: add a timeout for socket operations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « commit-queue/commit_queue.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding=utf8 1 # coding=utf8
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 """Postpone commits until the tree is open.""" 5 """Postpone commits until the tree is open."""
6 6
7 import calendar 7 import calendar
8 import json 8 import json
9 import logging 9 import logging
10 import ssl
10 import time 11 import time
11 import urllib2 12 import urllib2
12 13
13 from verification import base 14 from verification import base
14 15
15 16
16 class TreeStatus(base.IVerifierStatus): 17 class TreeStatus(base.IVerifierStatus):
17 tree_status_url = unicode 18 tree_status_url = unicode
18 issue = int 19 issue = int
19 last_tree_status = unicode 20 last_tree_status = unicode
(...skipping 19 matching lines...) Expand all
39 for item in sorted(data, key=lambda x: x['date'], reverse=True): 40 for item in sorted(data, key=lambda x: x['date'], reverse=True):
40 if item['general_state'] != 'open': 41 if item['general_state'] != 'open':
41 logging.warn( 42 logging.warn(
42 'Not committing CL %d because the tree was closed %ds ago', 43 'Not committing CL %d because the tree was closed %ds ago',
43 self.issue, int(now - item['date'])) 44 self.issue, int(now - item['date']))
44 self.last_tree_status = unicode(item['message']) 45 self.last_tree_status = unicode(item['message'])
45 return True 46 return True
46 if item['date'] < cutoff: 47 if item['date'] < cutoff:
47 break 48 break
48 return False 49 return False
49 except (urllib2.URLError, ValueError): 50 except (ssl.SSLError, urllib2.URLError, ValueError):
50 logging.error('Failed to request tree status! %s' % url) 51 logging.error('Failed to request tree status! %s' % url)
51 return True 52 return True
52 53
53 def why_not(self): 54 def why_not(self):
54 if self.last_tree_status: 55 if self.last_tree_status:
55 return u'Tree is currently not open: %s' % self.last_tree_status 56 return u'Tree is currently not open: %s' % self.last_tree_status
56 57
57 58
58 class TreeStatusVerifier(base.Verifier): 59 class TreeStatusVerifier(base.Verifier):
59 """Checks the tree status before allowing a commit.""" 60 """Checks the tree status before allowing a commit."""
60 name = 'tree status' 61 name = 'tree status'
61 62
62 def __init__(self, tree_status_url): 63 def __init__(self, tree_status_url):
63 super(TreeStatusVerifier, self).__init__() 64 super(TreeStatusVerifier, self).__init__()
64 self.tree_status_url = tree_status_url 65 self.tree_status_url = tree_status_url
65 66
66 def verify(self, pending): 67 def verify(self, pending):
67 pending.verifications[self.name] = TreeStatus( 68 pending.verifications[self.name] = TreeStatus(
68 tree_status_url=self.tree_status_url, issue=pending.issue) 69 tree_status_url=self.tree_status_url, issue=pending.issue)
69 70
70 def update_status(self, queue): 71 def update_status(self, queue):
71 pass 72 pass
OLDNEW
« no previous file with comments | « commit-queue/commit_queue.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698