2020-11-21 19:35:29 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
from requests import get
|
|
|
|
from sys import exit
|
|
|
|
|
|
|
|
api_key = '${api_key}'
|
|
|
|
|
|
|
|
try:
|
|
|
|
json = get('http://[::1]:22030/plugin/softwareupdate/check', headers={'X-Api-Key': api_key}).json()
|
|
|
|
except Exception as e:
|
|
|
|
print(repr(e))
|
|
|
|
exit(3)
|
|
|
|
|
|
|
|
updates = set()
|
|
|
|
|
|
|
|
for identifier, info in json['information'].items():
|
|
|
|
if info['updateAvailable']:
|
2020-12-23 09:43:13 +00:00
|
|
|
updates.add('{} ({} → {})'.format(
|
2020-12-23 11:38:44 +00:00
|
|
|
info['displayName'],
|
2020-12-23 09:43:13 +00:00
|
|
|
info['information']['local']['value'],
|
|
|
|
info['information']['remote']['value'],
|
|
|
|
))
|
2020-11-21 19:35:29 +00:00
|
|
|
|
|
|
|
if len(updates) > 0:
|
|
|
|
print('Updates available: {}'.format(', '.join(sorted(updates))))
|
|
|
|
exit(2)
|
|
|
|
else:
|
|
|
|
print('OK')
|
|
|
|
exit(0)
|