| OLD | NEW |
| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 def get_issue_properties(self, issue, messages): | 78 def get_issue_properties(self, issue, messages): |
| 79 """Returns all the issue's metadata as a dictionary.""" | 79 """Returns all the issue's metadata as a dictionary.""" |
| 80 url = '/api/%d' % issue | 80 url = '/api/%d' % issue |
| 81 if messages: | 81 if messages: |
| 82 url += '?messages=true' | 82 url += '?messages=true' |
| 83 data = json.loads(self.get(url, retry_on_404=True)) | 83 data = json.loads(self.get(url, retry_on_404=True)) |
| 84 data['description'] = '\n'.join(data['description'].strip().splitlines()) | 84 data['description'] = '\n'.join(data['description'].strip().splitlines()) |
| 85 return data | 85 return data |
| 86 | 86 |
| 87 def get_depends_on_patchset(self, issue, patchset): | |
| 88 """Returns the patchset this patchset depends on if it exists.""" | |
| 89 url = '/%d/patchset/%d/get_depends_on_patchset' % (issue, patchset) | |
| 90 resp = None | |
| 91 try: | |
| 92 resp = json.loads(self.get(url)) | |
| 93 except urllib2.HTTPError: | |
| 94 # The get_depends_on_patchset endpoint does not exist on this Rietveld | |
| 95 # instance yet. Ignore the error and proceed. | |
| 96 # TODO(rmistry): Make this an error when all Rietveld instances have | |
| 97 # this endpoint. | |
| 98 pass | |
| 99 return resp | |
| 100 | |
| 101 def get_patchset_properties(self, issue, patchset): | 87 def get_patchset_properties(self, issue, patchset): |
| 102 """Returns the patchset properties.""" | 88 """Returns the patchset properties.""" |
| 103 url = '/api/%d/%d' % (issue, patchset) | 89 url = '/api/%d/%d' % (issue, patchset) |
| 104 return json.loads(self.get(url)) | 90 return json.loads(self.get(url)) |
| 105 | 91 |
| 106 def get_file_content(self, issue, patchset, item): | 92 def get_file_content(self, issue, patchset, item): |
| 107 """Returns the content of a new file. | 93 """Returns the content of a new file. |
| 108 | 94 |
| 109 Throws HTTP 302 exception if the file doesn't exist or is not a binary file. | 95 Throws HTTP 302 exception if the file doesn't exist or is not a binary file. |
| 110 """ | 96 """ |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 ReadOnlyRietveld._local_changes.setdefault(issue, {})['closed'] = True | 670 ReadOnlyRietveld._local_changes.setdefault(issue, {})['closed'] = True |
| 685 | 671 |
| 686 def get_issue_properties(self, issue, messages): | 672 def get_issue_properties(self, issue, messages): |
| 687 data = self._rietveld.get_issue_properties(issue, messages) | 673 data = self._rietveld.get_issue_properties(issue, messages) |
| 688 data.update(self._get_local_changes(issue)) | 674 data.update(self._get_local_changes(issue)) |
| 689 return data | 675 return data |
| 690 | 676 |
| 691 def get_patchset_properties(self, issue, patchset): | 677 def get_patchset_properties(self, issue, patchset): |
| 692 return self._rietveld.get_patchset_properties(issue, patchset) | 678 return self._rietveld.get_patchset_properties(issue, patchset) |
| 693 | 679 |
| 694 def get_depends_on_patchset(self, issue, patchset): | |
| 695 return self._rietveld.get_depends_on_patchset(issue, patchset) | |
| 696 | |
| 697 def get_patch(self, issue, patchset): | 680 def get_patch(self, issue, patchset): |
| 698 return self._rietveld.get_patch(issue, patchset) | 681 return self._rietveld.get_patch(issue, patchset) |
| 699 | 682 |
| 700 def update_description(self, issue, description): # pylint:disable=R0201 | 683 def update_description(self, issue, description): # pylint:disable=R0201 |
| 701 logging.info('ReadOnlyRietveld: new description for issue %d: %s' % | 684 logging.info('ReadOnlyRietveld: new description for issue %d: %s' % |
| 702 (issue, description)) | 685 (issue, description)) |
| 703 | 686 |
| 704 def add_comment(self, # pylint:disable=R0201 | 687 def add_comment(self, # pylint:disable=R0201 |
| 705 issue, | 688 issue, |
| 706 message, | 689 message, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 717 self, issue, patchset, reason, clobber, revision, builders_and_tests, | 700 self, issue, patchset, reason, clobber, revision, builders_and_tests, |
| 718 master=None, category='cq'): | 701 master=None, category='cq'): |
| 719 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % | 702 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % |
| 720 (builders_and_tests, issue)) | 703 (builders_and_tests, issue)) |
| 721 | 704 |
| 722 def trigger_distributed_try_jobs( # pylint:disable=R0201 | 705 def trigger_distributed_try_jobs( # pylint:disable=R0201 |
| 723 self, issue, patchset, reason, clobber, revision, masters, | 706 self, issue, patchset, reason, clobber, revision, masters, |
| 724 category='cq'): | 707 category='cq'): |
| 725 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % | 708 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % |
| 726 (masters, issue)) | 709 (masters, issue)) |
| OLD | NEW |