Remove now unused code to fetch errors from remote host

This commit is contained in:
Lonami Exo 2018-12-03 15:53:08 +01:00
parent 01848de7e2
commit 4901447ad6

View File

@ -1,30 +0,0 @@
import sys
import json
import urllib.request
FILES = (
('data/errors.json', 'https://rpc.pwrtelegram.xyz/?all'),
('data/invalid_bot_methods.json', 'https://rpc.pwrtelegram.xyz/?bot')
)
def fetch_json(output, url):
r = urllib.request.urlopen(urllib.request.Request(
url, headers={'User-Agent' : 'Mozilla/5.0'}
))
data = json.loads(
r.read().decode(r.info().get_param('charset') or 'utf-8')
)
if data.get('ok'):
del data['ok']
if len(data) == 1:
data = data[next(iter(data.keys()))]
with open(output, 'w', encoding='utf-8') as f:
json.dump(data, f, sort_keys=True)
else:
print(json.dumps(data, indent=4, sort_keys=True), file=sys.stderr)
if __name__ == '__main__':
for output, url in FILES:
fetch_json(output, url)