Add progress indicator that prints a dot on nearly each RPCs request
R=tandrii@chromium.org
Change-Id: Id4fa494c8225c8edefecba064445504065581478
Reviewed-on: https://chromium-review.googlesource.com/966564
Commit-Queue: Sergiy Byelozyorov <sergiyb@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Reviewed-by: Sergiy Byelozyorov <sergiyb@chromium.org>
diff --git a/my_activity.py b/my_activity.py
index 239f5b8..393cbda 100755
--- a/my_activity.py
+++ b/my_activity.py
@@ -197,6 +197,11 @@
self.check_cookies()
self.google_code_auth_token = None
+ def show_progress(self, how='.'):
+ if sys.stdout.isatty():
+ sys.stdout.write(how)
+ sys.stdout.flush()
+
# Check the codereview cookie jar to determine which Rietveld instances to
# authenticate to.
def check_cookies(self):
@@ -245,6 +250,7 @@
reviewer=reviewer_email,
modified_after=query_modified_after,
with_messages=True)
+ self.show_progress()
issues = filter(
lambda i: (datetime_from_rietveld(i['created']) < self.modified_before),
@@ -294,6 +300,7 @@
patchset_props = remote.get_patchset_properties(
issue['issue'],
issue['patchsets'][-1])
+ self.show_progress()
ret['delta'] = '+%d,-%d' % (
sum(f['num_added'] for f in patchset_props['files'].itervalues()),
sum(f['num_removed'] for f in patchset_props['files'].itervalues()))
@@ -365,6 +372,7 @@
filters = ['-age:%ss' % max_age, user_filter]
issues = self.gerrit_changes_over_rest(instance, filters)
+ self.show_progress()
issues = [self.process_gerrit_issue(instance, issue)
for issue in issues]
@@ -443,6 +451,7 @@
url = ('https://monorail-prod.appspot.com/_ah/api/monorail/v1/projects'
'/%s/issues/%s/comments?maxResults=10000') % (project, issue_id)
_, body = http.request(url)
+ self.show_progress()
content = json.loads(body)
if not content:
logging.error('Unable to parse %s response from monorail.', project)
@@ -462,6 +471,7 @@
query_data = urllib.urlencode(query)
url = url + '?' + query_data
_, body = http.request(url)
+ self.show_progress()
content = json.loads(body)
if not content:
logging.error('Unable to parse %s response from monorail.', project)
@@ -980,6 +990,7 @@
logging.info('Using range %s to %s', options.begin, options.end)
my_activity = MyActivity(options)
+ my_activity.show_progress('Loading data')
if not (options.changes or options.reviews or options.issues or
options.changes_by_issue):
@@ -1008,6 +1019,8 @@
except auth.AuthenticationError as e:
logging.error('auth.AuthenticationError: %s', e)
+ my_activity.show_progress('\n')
+
output_file = None
try:
if options.output: