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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 svn_props.append((match.group(2), match2.group(1))) | 219 svn_props.append((match.group(2), match2.group(1))) |
220 return svn_props | 220 return svn_props |
221 | 221 |
222 def update_description(self, issue, description): | 222 def update_description(self, issue, description): |
223 """Sets the description for an issue on Rietveld.""" | 223 """Sets the description for an issue on Rietveld.""" |
224 logging.info('new description for issue %d' % issue) | 224 logging.info('new description for issue %d' % issue) |
225 self.post('/%d/description' % issue, [ | 225 self.post('/%d/description' % issue, [ |
226 ('description', description), | 226 ('description', description), |
227 ('xsrf_token', self.xsrf_token())]) | 227 ('xsrf_token', self.xsrf_token())]) |
228 | 228 |
229 def add_comment(self, issue, message): | 229 def add_comment(self, issue, message, add_as_reviewer=False): |
230 max_message = 10000 | 230 max_message = 10000 |
231 tail = '…\n(message too large)' | 231 tail = '…\n(message too large)' |
232 if len(message) > max_message: | 232 if len(message) > max_message: |
233 message = message[:max_message-len(tail)] + tail | 233 message = message[:max_message-len(tail)] + tail |
234 logging.info('issue %d; comment: %s' % (issue, message)) | 234 logging.info('issue %d; comment: %s' % (issue, message)) |
235 return self.post('/%d/publish' % issue, [ | 235 return self.post('/%d/publish' % issue, [ |
236 ('xsrf_token', self.xsrf_token()), | 236 ('xsrf_token', self.xsrf_token()), |
237 ('message', message), | 237 ('message', message), |
238 ('message_only', 'True'), | 238 ('message_only', 'True'), |
| 239 ('add_as_reviewer', str(bool(add_as_reviewer))), |
239 ('send_mail', 'True'), | 240 ('send_mail', 'True'), |
240 ('no_redirect', 'True')]) | 241 ('no_redirect', 'True')]) |
241 | 242 |
242 def set_flag(self, issue, patchset, flag, value): | 243 def set_flag(self, issue, patchset, flag, value): |
243 return self.post('/%d/edit_flags' % issue, [ | 244 return self.post('/%d/edit_flags' % issue, [ |
244 ('last_patchset', str(patchset)), | 245 ('last_patchset', str(patchset)), |
245 ('xsrf_token', self.xsrf_token()), | 246 ('xsrf_token', self.xsrf_token()), |
246 (flag, value)]) | 247 (flag, value)]) |
247 | 248 |
248 def search( | 249 def search( |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 if not 'Name or service not known' in e.reason: | 373 if not 'Name or service not known' in e.reason: |
373 # Usually internal GAE flakiness. | 374 # Usually internal GAE flakiness. |
374 raise | 375 raise |
375 # If reaching this line, loop again. Uses a small backoff. | 376 # If reaching this line, loop again. Uses a small backoff. |
376 time.sleep(1+maxtries*2) | 377 time.sleep(1+maxtries*2) |
377 finally: | 378 finally: |
378 upload.ErrorExit = old_error_exit | 379 upload.ErrorExit = old_error_exit |
379 | 380 |
380 # DEPRECATED. | 381 # DEPRECATED. |
381 Send = get | 382 Send = get |
OLD | NEW |