psss / did

What did you do last week, month, year?
https://did.readthedocs.io/
GNU General Public License v2.0
247 stars 104 forks source link

if owner is not found in gerrit throws error #131

Open epcim opened 7 years ago

epcim commented 7 years ago

I have multiple users,emails configured in general section. I use multiple gerrits.

 DEBUG  url = https://gerrit.mcp.xyz.net/changes/?q=status:abandoned+owner:epcim+-age:11d#/
Traceback (most recent call last):
  File "/usr/local/bin/did", line 42, in <module>
    did.cli.main()
  File "/usr/local/lib/python2.7/dist-packages/did/cli.py", line 190, in main
    user_stats.check()
  File "/usr/local/lib/python2.7/dist-packages/did/stats.py", line 134, in check
    stat.check()
  File "/usr/local/lib/python2.7/dist-packages/did/stats.py", line 134, in check
    stat.check()
  File "/usr/local/lib/python2.7/dist-packages/did/stats.py", line 79, in check
    self.fetch()
  File "/usr/local/lib/python2.7/dist-packages/did/plugins/gerrit.py", line 199, in fetch
    self.stats = GerritUnit.fetch(self, 'status:abandoned')
  File "/usr/local/lib/python2.7/dist-packages/did/plugins/gerrit.py", line 173, in fetch
    work_list = self.repo.search(query_string)
  File "/usr/local/lib/python2.7/dist-packages/did/plugins/gerrit.py", line 97, in search
    tickets = self.get_query_result(full_url)
  File "/usr/local/lib/python2.7/dist-packages/did/plugins/gerrit.py", line 70, in get_query_result
    'Cannot retrieve list of changes ({0})'.format(res.getcode()))
IOError: Cannot retrieve list of changes (400)
epcim commented 7 years ago

Poor fix was like handle 400 error code, gerrit.py:

    curl -s 'https://REPOURL/gerrit/changes/?q=is:abandoned+age:7d' ----------------
   def __init__(self, baseurl, prefix): --------------------------------------------
   def join_URL_frags(base, query): ------------------------------------------------
   def get_query_result(self, url):
       log.debug('url = {0}'.format(url))                                           
       res = self.opener.open(url)
       if res.getcode() != 200 and res.getcode() != 400:
           raise IOError(
               'Cannot retrieve list of changes ({0})'.format(res.getcode()))
       if res.getcode() == 400:
         return {}

res(ponse) in such case contains 'epcim was not found' (where epcim is owner). possibly related to #132