Skip to content

Instantly share code, notes, and snippets.

@abitrolly
Created August 12, 2018 05:48
Show Gist options
  • Save abitrolly/db187a20422c7889a2390146cbbaed6f to your computer and use it in GitHub Desktop.
Save abitrolly/db187a20422c7889a2390146cbbaed6f to your computer and use it in GitHub Desktop.
Refresh failed Anitya updates
#!/usr/bin/env python3
import requests
ANITYA = 'https://release-monitoring.org'
# projects seen in this session (should be equal to page size)
count = 0
# (GitHub) projects processed this session
processed = 0
# GitHub projects successfully processed with this script while debugging
github = 70
# #access internal iterator of for loop
ilines = requests.get(ANITYA + '/projects/updates/failed').iter_lines()
for line in ilines:
# line is in bytes
linestr = line.decode().strip()
if linestr.startswith('<a href="/project/'):
count += 1
data = linestr.split('/')
id_ = data[2]
name = next(ilines).decode().strip()
print(f'checking {id_:7} {name:20} - ', end='')
project = requests.get(f'{ANITYA}/api/project/{id_}').json()
if project['backend'] == 'GitHub':
resp = requests.post(ANITYA + '/api/version/get', data={'id': id_})
# #rsp.status
if resp.status_code == 200:
processed += 1
github += 1
print(resp.status_code)
else:
print(f'ERROR {resp.status_code}')
# #rsp.json
print(resp.json())
else:
print(f'SKIP {project["backend"]}')
print(f'seen {count} projects, processed {processed}, total github {github}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment