OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
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 | 5 |
6 """\ | 6 """\ |
7 Wrapper script around Rietveld's upload.py that simplifies working with groups | 7 Wrapper script around Rietveld's upload.py that simplifies working with groups |
8 of files. | 8 of files. |
9 """ | 9 """ |
10 | 10 |
11 import json | 11 import json |
12 import optparse | 12 import optparse |
13 import os | 13 import os |
14 import random | 14 import random |
15 import re | 15 import re |
| 16 import ssl |
16 import string | 17 import string |
17 import sys | 18 import sys |
18 import tempfile | 19 import tempfile |
19 import time | 20 import time |
20 import urllib2 | 21 import urllib2 |
21 | 22 |
22 import breakpad # pylint: disable=W0611 | 23 import breakpad # pylint: disable=W0611 |
23 | 24 |
24 | 25 |
25 import fix_encoding | 26 import fix_encoding |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 | 394 |
394 def AddComment(self, comment): | 395 def AddComment(self, comment): |
395 """Adds a comment for an issue on Rietveld. | 396 """Adds a comment for an issue on Rietveld. |
396 As a side effect, this will email everyone associated with the issue.""" | 397 As a side effect, this will email everyone associated with the issue.""" |
397 return self.RpcServer().add_comment(self.issue, comment) | 398 return self.RpcServer().add_comment(self.issue, comment) |
398 | 399 |
399 def PrimeLint(self): | 400 def PrimeLint(self): |
400 """Do background work on Rietveld to lint the file so that the results are | 401 """Do background work on Rietveld to lint the file so that the results are |
401 ready when the issue is viewed.""" | 402 ready when the issue is viewed.""" |
402 if self.issue and self.patchset: | 403 if self.issue and self.patchset: |
403 self.SendToRietveld('/lint/issue%s_%s' % (self.issue, self.patchset), | 404 try: |
404 timeout=10) | 405 self.SendToRietveld('/lint/issue%s_%s' % (self.issue, self.patchset), |
| 406 timeout=10) |
| 407 except ssl.SSLError as e: |
| 408 # It takes more than 10 seconds to lint some CLs. Silently ignore |
| 409 # the expected timeout. |
| 410 if e.message != 'The read operation timed out': |
| 411 raise |
405 | 412 |
406 def SendToRietveld(self, request_path, timeout=None, **kwargs): | 413 def SendToRietveld(self, request_path, timeout=None, **kwargs): |
407 """Send a POST/GET to Rietveld. Returns the response body.""" | 414 """Send a POST/GET to Rietveld. Returns the response body.""" |
408 try: | 415 try: |
409 return self.RpcServer().Send(request_path, timeout=timeout, **kwargs) | 416 return self.RpcServer().Send(request_path, timeout=timeout, **kwargs) |
410 except urllib2.URLError: | 417 except urllib2.URLError: |
411 if timeout is None: | 418 if timeout is None: |
412 ErrorExit('Error accessing url %s' % request_path) | 419 ErrorExit('Error accessing url %s' % request_path) |
413 else: | 420 else: |
414 return None | 421 return None |
(...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1477 raise | 1484 raise |
1478 print >> sys.stderr, ( | 1485 print >> sys.stderr, ( |
1479 'AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 1486 'AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
1480 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)) | 1487 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)) |
1481 return 1 | 1488 return 1 |
1482 | 1489 |
1483 | 1490 |
1484 if __name__ == "__main__": | 1491 if __name__ == "__main__": |
1485 fix_encoding.fix_encoding() | 1492 fix_encoding.fix_encoding() |
1486 sys.exit(main(sys.argv[1:])) | 1493 sys.exit(main(sys.argv[1:])) |
OLD | NEW |