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

Side by Side Diff: rietveld.py

Issue 1063263002: Remove 'email', 'password' and 'private_key_file' properties of Rietveld class. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 5 years, 8 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 | 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: 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 21 matching lines...) Expand all
32 32
33 # Appengine replies with 302 when authentication fails (sigh.) 33 # Appengine replies with 302 when authentication fails (sigh.)
34 oa2client.REFRESH_STATUS_CODES.append(302) 34 oa2client.REFRESH_STATUS_CODES.append(302)
35 upload.LOGGER.setLevel(logging.WARNING) # pylint: disable=E1103 35 upload.LOGGER.setLevel(logging.WARNING) # pylint: disable=E1103
36 36
37 37
38 class Rietveld(object): 38 class Rietveld(object):
39 """Accesses rietveld.""" 39 """Accesses rietveld."""
40 def __init__(self, url, email, password, extra_headers=None, maxtries=None): 40 def __init__(self, url, email, password, extra_headers=None, maxtries=None):
41 self.url = url.rstrip('/') 41 self.url = url.rstrip('/')
42 # Email and password are accessed by commit queue, keep them. 42
43 self.email = email
44 self.password = password
45 # TODO(maruel): It's not awesome but maybe necessary to retrieve the value. 43 # TODO(maruel): It's not awesome but maybe necessary to retrieve the value.
46 # It happens when the presubmit check is ran out of process, the cookie 44 # It happens when the presubmit check is ran out of process, the cookie
47 # needed to be recreated from the credentials. Instead, it should pass the 45 # needed to be recreated from the credentials. Instead, it should pass the
48 # email and the cookie. 46 # email and the cookie.
49 if email and password: 47 if email and password:
50 get_creds = lambda: (email, password) 48 get_creds = lambda: (email, password)
51 self.rpc_server = upload.HttpRpcServer( 49 self.rpc_server = upload.HttpRpcServer(
52 self.url, 50 self.url,
53 get_creds, 51 get_creds,
54 extra_headers=extra_headers or {}) 52 extra_headers=extra_headers or {})
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 # The parent__init__ is not called on purpose. 570 # The parent__init__ is not called on purpose.
573 # pylint: disable=W0231 571 # pylint: disable=W0231
574 def __init__(self, 572 def __init__(self,
575 url, 573 url,
576 client_email, 574 client_email,
577 client_private_key_file, 575 client_private_key_file,
578 private_key_password=None, 576 private_key_password=None,
579 extra_headers=None, 577 extra_headers=None,
580 maxtries=None): 578 maxtries=None):
581 579
582 # These attributes are accessed by commit queue. Keep them.
583 self.email = client_email
584 self.private_key_file = client_private_key_file
585
586 if private_key_password is None: # '' means 'empty password' 580 if private_key_password is None: # '' means 'empty password'
587 private_key_password = 'notasecret' 581 private_key_password = 'notasecret'
588 582
589 self.url = url.rstrip('/') 583 self.url = url.rstrip('/')
590 bot_url = self.url + '/bots' 584 bot_url = self.url + '/bots'
591 585
592 with open(client_private_key_file, 'rb') as f: 586 with open(client_private_key_file, 'rb') as f:
593 client_private_key = f.read() 587 client_private_key = f.read()
594 logging.info('Using OAuth login: %s' % client_email) 588 logging.info('Using OAuth login: %s' % client_email)
595 self.rpc_server = OAuthRpcServer(bot_url, 589 self.rpc_server = OAuthRpcServer(bot_url,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 665
672 @classmethod 666 @classmethod
673 def _get_local_changes(cls, issue): 667 def _get_local_changes(cls, issue):
674 """Returns dictionary of local changes for |issue|, if any.""" 668 """Returns dictionary of local changes for |issue|, if any."""
675 return cls._local_changes.get(issue, {}) 669 return cls._local_changes.get(issue, {})
676 670
677 @property 671 @property
678 def url(self): 672 def url(self):
679 return self._rietveld.url 673 return self._rietveld.url
680 674
681 @property
682 def email(self):
683 return self._rietveld.email
684
685 @property
686 def password(self):
687 return self._rietveld.password
688
689 def get_pending_issues(self): 675 def get_pending_issues(self):
690 pending_issues = self._rietveld.get_pending_issues() 676 pending_issues = self._rietveld.get_pending_issues()
691 677
692 # Filter out issues we've closed or unchecked the commit checkbox. 678 # Filter out issues we've closed or unchecked the commit checkbox.
693 return [issue for issue in pending_issues 679 return [issue for issue in pending_issues
694 if not self._get_local_changes(issue).get('closed', False) and 680 if not self._get_local_changes(issue).get('closed', False) and
695 self._get_local_changes(issue).get('commit', True)] 681 self._get_local_changes(issue).get('commit', True)]
696 682
697 def close_issue(self, issue): # pylint:disable=R0201 683 def close_issue(self, issue): # pylint:disable=R0201
698 logging.info('ReadOnlyRietveld: closing issue %d' % issue) 684 logging.info('ReadOnlyRietveld: closing issue %d' % issue)
(...skipping 30 matching lines...) Expand all
729 self, issue, patchset, reason, clobber, revision, builders_and_tests, 715 self, issue, patchset, reason, clobber, revision, builders_and_tests,
730 master=None, category='cq'): 716 master=None, category='cq'):
731 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % 717 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' %
732 (builders_and_tests, issue)) 718 (builders_and_tests, issue))
733 719
734 def trigger_distributed_try_jobs( # pylint:disable=R0201 720 def trigger_distributed_try_jobs( # pylint:disable=R0201
735 self, issue, patchset, reason, clobber, revision, masters, 721 self, issue, patchset, reason, clobber, revision, masters,
736 category='cq'): 722 category='cq'):
737 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % 723 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' %
738 (masters, issue)) 724 (masters, issue))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698