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

Unified Diff: reviewbot/rietveld.py

Issue 23531026: Remove the review bot app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/
Patch Set: Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « reviewbot/review.py ('k') | reviewbot/third_party.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: reviewbot/rietveld.py
===================================================================
--- reviewbot/rietveld.py (revision 221173)
+++ reviewbot/rietveld.py (working copy)
@@ -1,94 +0,0 @@
-# Copyright (c) 2013 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-from oauth2client.client import SignedJwtAssertionCredentials
-import httplib2
-import model.app_config
-import urllib
-import util
-
-
-EMAIL_SCOPE = 'https://www.googleapis.com/auth/userinfo.email'
-
-
-class RietveldRequestError(Exception):
- """Raised on request errors."""
- pass
-
-
-class Rietveld(object):
- """Implements a Python API to access rietveld via HTTP.
-
- Authentication is handled via an OAuth2 access token minted from an RSA key
- associated with a service account (which can be created via the Google API
- console). For this to work, the Rietveld instance to talk to must be
- configured to allow the service account client ID as OAuth2 audience (see
- Rietveld source). Both the RSA key and the server URL are provided via static
- application configuration.
- """
-
- def __init__(self):
- self.app_config = model.app_config.get()
-
- @util.lazy_property
- def http(self):
- http = httplib2.Http()
-
- creds = SignedJwtAssertionCredentials(self.app_config.client_id,
- self.app_config.service_account_key,
- EMAIL_SCOPE)
- creds.authorize(http)
- return http
-
- @util.lazy_property
- def xsrf_token(self):
- return self.make_request('xsrf_token',
- headers={'X-Requesting-XSRF-Token': 1})
-
- def make_request(self, req, *args, **kwargs):
- resp, response = self.http.request(
- '%s/%s' % (self.app_config.server_url, req), *args, **kwargs)
- if resp.status != 200:
- raise RietveldRequestError(
- 'Rietveld %s request failed: %s\n%s' %
- (req, resp.status, str(resp)), resp, response)
-
- return response
-
- def post_data(self, req, payload=None):
- actual_payload = dict(payload or {})
- actual_payload['xsrf_token'] = self.xsrf_token
-
- return self.make_request(req, method='POST',
- body=urllib.urlencode(actual_payload))
-
- def post_issue_data(self, issue, req, payload):
- return self.post_data('%s/%s' % (issue, req), payload)
-
- def publish_inline_comments(self, issue, comment, reviewers, cc,
- subject=None, send_mail=False):
- publish_payload = {
- 'cc': cc,
- 'message': comment,
- 'message_only': 0,
- 'no_redirect': 1,
- 'reviewers': reviewers,
- 'send_mail': 1 if send_mail else 0,
- }
- if subject is not None:
- publish_payload['subject'] = subject
- self.post_issue_data(issue, 'publish', publish_payload)
-
- def add_inline_comment(self, issue_id, patchset_id, patch_id, line, a_or_b,
- comment):
- comment_payload = {
- 'snapshot': 'old' if a_or_b is 'a' else 'new',
- 'lineno': line,
- 'side': a_or_b,
- 'issue': issue_id,
- 'patchset': patchset_id,
- 'patch': patch_id,
- 'text': comment,
- }
- self.post_data('inline_draft', comment_payload)
« no previous file with comments | « reviewbot/review.py ('k') | reviewbot/third_party.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698