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

Unified Diff: my_activity.py

Issue 50283002: my_activity: Port gerrit to the new gerrit_util API. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: added check for len(more_changes) < 2 Created 7 years, 1 month 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 | « gerrit_util.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: my_activity.py
diff --git a/my_activity.py b/my_activity.py
index 3d73c8b1c3908853d714b14754f412203eb43ddd..09dc0fb3ca7701ee47219dc37356d67c3e924d07 100755
--- a/my_activity.py
+++ b/my_activity.py
@@ -35,6 +35,7 @@ import sys
import urllib
import urllib2
+import gerrit_util
import rietveld
from third_party import upload
@@ -119,12 +120,10 @@ gerrit_instances = [
'url': 'chromium-review.googlesource.com',
'shorturl': 'crosreview.com',
},
- # TODO(deymo): chrome-internal-review requires login credentials. Enable once
- # login support is added to this client. See crbug.com/281695.
- #{
- # 'url': 'chrome-internal-review.googlesource.com',
- # 'shorturl': 'crosreview.com/i',
- #},
+ {
+ 'url': 'chrome-internal-review.googlesource.com',
+ 'shorturl': 'crosreview.com/i',
+ },
{
'host': 'gerrit.chromium.org',
'port': 29418,
@@ -405,27 +404,16 @@ class MyActivity(object):
@staticmethod
def gerrit_changes_over_rest(instance, filters):
- # See https://gerrit-review.googlesource.com/Documentation/rest-api.html
- # Gerrit doesn't allow filtering by created time, only modified time.
- args = urllib.urlencode([
- ('q', ' '.join(filters)),
- ('o', 'MESSAGES'),
- ('o', 'LABELS')])
- rest_url = 'https://%s/changes/?%s' % (instance['url'], args)
-
- req = urllib2.Request(rest_url, headers={'Accept': 'text/plain'})
+ # Convert the "key:value" filter to a dictionary.
+ req = dict(f.split(':', 1) for f in filters)
try:
- response = urllib2.urlopen(req)
- stdout = response.read()
- except urllib2.HTTPError, e:
- print 'ERROR: Looking up %r: %s' % (rest_url, e)
- return []
-
- # Check that the returned JSON starts with the right marker.
- if stdout[:5] != ")]}'\n":
- print 'ERROR: Marker not found on REST API response: %r' % stdout[:5]
+ # Instantiate the generator to force all the requests now and catch the
+ # errors here.
+ return list(gerrit_util.GenerateAllChanges(instance['url'], req,
+ o_params=['MESSAGES', 'LABELS', 'DETAILED_ACCOUNTS']))
+ except gerrit_util.GerritError, e:
+ print 'ERROR: Looking up %r: %s' % (instance['url'], e)
return []
- return json.loads(stdout[5:])
def gerrit_search(self, instance, owner=None, reviewer=None):
max_age = datetime.today() - self.modified_after
@@ -506,7 +494,8 @@ class MyActivity(object):
@staticmethod
def process_gerrit_rest_issue_replies(replies):
ret = []
- replies = filter(lambda r: 'email' in r['author'], replies)
+ replies = filter(lambda r: 'author' in r and 'email' in r['author'],
+ replies)
for reply in replies:
ret.append({
'author': reply['author']['email'],
« no previous file with comments | « gerrit_util.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698