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

Side by Side Diff: rietveld.py

Issue 174313002: Added a default timeout to rietveld requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Addressing comments Created 6 years, 10 months 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
« no previous file with comments | « no previous file | tests/rietveld_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
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 """Defines class Rietveld to easily access a rietveld instance. 5 """Defines class Rietveld to easily access a rietveld instance.
6 6
7 Security implications: 7 Security implications:
8 8
9 The following hypothesis are made: 9 The following hypothesis are made:
10 - Rietveld enforces: 10 - Rietveld enforces:
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 def get(self, request_path, **kwargs): 360 def get(self, request_path, **kwargs):
361 kwargs.setdefault('payload', None) 361 kwargs.setdefault('payload', None)
362 return self._send(request_path, **kwargs) 362 return self._send(request_path, **kwargs)
363 363
364 def post(self, request_path, data, **kwargs): 364 def post(self, request_path, data, **kwargs):
365 ctype, body = upload.EncodeMultipartFormData(data, []) 365 ctype, body = upload.EncodeMultipartFormData(data, [])
366 return self._send(request_path, payload=body, content_type=ctype, **kwargs) 366 return self._send(request_path, payload=body, content_type=ctype, **kwargs)
367 367
368 def _send(self, request_path, **kwargs): 368 def _send(self, request_path, **kwargs):
369 """Sends a POST/GET to Rietveld. Returns the response body.""" 369 """Sends a POST/GET to Rietveld. Returns the response body."""
370 # rpc_server.Send() assumes timeout=None by default; make sure it's set
371 # to something reasonable.
372 kwargs.setdefault('timeout', 15)
370 logging.debug('POSTing to %s, args %s.', request_path, kwargs) 373 logging.debug('POSTing to %s, args %s.', request_path, kwargs)
371 try: 374 try:
372 # Sadly, upload.py calls ErrorExit() which does a sys.exit(1) on HTTP 375 # Sadly, upload.py calls ErrorExit() which does a sys.exit(1) on HTTP
373 # 500 in AbstractRpcServer.Send(). 376 # 500 in AbstractRpcServer.Send().
374 old_error_exit = upload.ErrorExit 377 old_error_exit = upload.ErrorExit
375 def trap_http_500(msg): 378 def trap_http_500(msg):
376 """Converts an incorrect ErrorExit() call into a HTTPError exception.""" 379 """Converts an incorrect ErrorExit() call into a HTTPError exception."""
377 m = re.search(r'(50\d) Server Error', msg) 380 m = re.search(r'(50\d) Server Error', msg)
378 if m: 381 if m:
379 # Fake an HTTPError exception. Cheezy. :( 382 # Fake an HTTPError exception. Cheezy. :(
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 529
527 def set_flag(self, issue, patchset, flag, value): # pylint:disable=R0201 530 def set_flag(self, issue, patchset, flag, value): # pylint:disable=R0201
528 logging.info('ReadOnlyRietveld: setting flag "%s" to "%s" for issue %d' % 531 logging.info('ReadOnlyRietveld: setting flag "%s" to "%s" for issue %d' %
529 (flag, value, issue)) 532 (flag, value, issue))
530 ReadOnlyRietveld._local_changes.setdefault(issue, {})[flag] = value 533 ReadOnlyRietveld._local_changes.setdefault(issue, {})[flag] = value
531 534
532 def trigger_try_jobs( # pylint:disable=R0201 535 def trigger_try_jobs( # pylint:disable=R0201
533 self, issue, patchset, reason, clobber, revision, builders_and_tests): 536 self, issue, patchset, reason, clobber, revision, builders_and_tests):
534 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % 537 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' %
535 (builders_and_tests, issue)) 538 (builders_and_tests, issue))
OLDNEW
« no previous file with comments | « no previous file | tests/rietveld_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698