Browse Source

my_activity: allow to exclude some servers

Not all my_activity.py users have accounts on all servers the utility
queries. This results in access errors reported when the utility is
ran.

Also, many users never upload patches on some servers even though the
account is there, there is no point in querying those servers.

This patch allows to pass in a list of servers to exclude from the
list of queried servers.

BUG=none
TEST=invoked the utility as follows:

  $ my_activity.py --skip_servers \
    pdfium-review.googlesource.com,skia-review.googlesource.com

  observed that the 'ERROR:root:Access Errors:' messages are not
  generated any more.

Change-Id: I7d676e45ee99d883a153b58acb778a2e2d5ed74a
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1487342
Reviewed-by: Aaron Gable <agable@chromium.org>
Vadim Bendebury 5 years ago
parent
commit
800129711d
1 changed files with 8 additions and 0 deletions
  1. 8 0
      my_activity.py

+ 8 - 0
my_activity.py

@@ -168,6 +168,7 @@ class MyActivity(object):
     self.referenced_issues = []
     self.google_code_auth_token = None
     self.access_errors = set()
+    self.skip_servers = (options.skip_servers.split(','))
 
   def show_progress(self, how='.'):
     if sys.stdout.isatty():
@@ -216,6 +217,8 @@ class MyActivity(object):
       return []
 
   def gerrit_search(self, instance, owner=None, reviewer=None):
+    if instance['url'] in self.skip_servers:
+      return []
     max_age = datetime.today() - self.modified_after
     filters = ['-age:%ss' % (max_age.days * 24 * 3600 + max_age.seconds)]
     if owner:
@@ -724,6 +727,11 @@ def main():
       help='Do not fetch issues referenced by owned changes. Useful in '
            'combination with --changes-by-issue when you only want to list '
            'issues that have also been modified in the same time period.')
+  parser.add_option(
+      '--skip_servers',
+      action='store',
+      default='',
+      help='A comma separated list of gerrit and rietveld servers to ignore')
   parser.add_option(
       '--skip-own-issues-without-changes',
       action='store_true',