-
Notifications
You must be signed in to change notification settings - Fork 8
/
check-anitya.py
executable file
·39 lines (28 loc) · 1.06 KB
/
check-anitya.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python
import requests
import sys
if __name__ == '__main__':
project = sys.argv[-1]
anitya_url = 'https://release-monitoring.org'
url = '%s/api/projects/?pattern=%s' % (anitya_url, project)
response = requests.get(url)
data = response.json()
if data['total'] < 1:
print "No project by the name of %r found." % project
sys.exit(1)
if data['total'] > 1:
print "Name %r ambiguous, %r entries found." % (project, data['total'])
sys.exit(2)
# OK - then we found the project. Now force a check.
idx = data['projects'][0]['id']
url = '%s/api/version/get' % anitya_url
resp = requests.post(url, data=dict(id=idx))
data = resp.json()
if 'error' in data:
print 'Anitya error: %r' % data['error']
sys.exit(3)
print "Check yielded upstream version %s for %s" % (
data['version'], data['name'])
if not any([p['distro'] == 'Fedora' for p in data['packages']]):
print "WARN: Not mapped to Fedora."
print "%s/project/%i" % (anitya_url, idx)