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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 url = '/api/%s/%s' % (issue, patchset) | 86 url = '/api/%s/%s' % (issue, patchset) |
87 return json.loads(self.get(url)) | 87 return json.loads(self.get(url)) |
88 | 88 |
89 def get_file_content(self, issue, patchset, item): | 89 def get_file_content(self, issue, patchset, item): |
90 """Returns the content of a new file. | 90 """Returns the content of a new file. |
91 | 91 |
92 Throws HTTP 302 exception if the file doesn't exist or is not a binary file. | 92 Throws HTTP 302 exception if the file doesn't exist or is not a binary file. |
93 """ | 93 """ |
94 # content = 0 is the old file, 1 is the new file. | 94 # content = 0 is the old file, 1 is the new file. |
95 content = 1 | 95 content = 1 |
96 url = '/%s/image/%s/%s/%s' % (issue, patchset, item, content) | 96 url = '/%s/binary/%s/%s/%s' % (issue, patchset, item, content) |
97 return self.get(url) | 97 return self.get(url) |
98 | 98 |
99 def get_file_diff(self, issue, patchset, item): | 99 def get_file_diff(self, issue, patchset, item): |
100 """Returns the diff of the file. | 100 """Returns the diff of the file. |
101 | 101 |
102 Returns a useless diff for binary files. | 102 Returns a useless diff for binary files. |
103 """ | 103 """ |
104 url = '/download/issue%s_%s_%s.diff' % (issue, patchset, item) | 104 url = '/download/issue%s_%s_%s.diff' % (issue, patchset, item) |
105 return self.get(url) | 105 return self.get(url) |
106 | 106 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 if not 'Name or service not known' in e.reason: | 336 if not 'Name or service not known' in e.reason: |
337 # Usually internal GAE flakiness. | 337 # Usually internal GAE flakiness. |
338 raise | 338 raise |
339 # If reaching this line, loop again. Uses a small backoff. | 339 # If reaching this line, loop again. Uses a small backoff. |
340 time.sleep(1+maxtries*2) | 340 time.sleep(1+maxtries*2) |
341 finally: | 341 finally: |
342 upload.ErrorExit = old_error_exit | 342 upload.ErrorExit = old_error_exit |
343 | 343 |
344 # DEPRECATED. | 344 # DEPRECATED. |
345 Send = get | 345 Send = get |
OLD | NEW |