
print("djjfjsafas")

import requests
import datetime
import gzip
import os

os.makedirs("history", exist_ok=True)
topusers = requests.get("http://www.primegrid.com/challenge/2019_1/top_users.xml.gz")

time = datetime.datetime.now()
filetime = f"{time.year}.{time.month:02}.{time.day:02}_{time.hour:02}.{time.minute:02}.{time.second:02}_UTC"
print(f"ran at {filetime}")

try:
    infile = gzip.decompress(topusers.content)
    with open(f"history/top_users.{filetime}.xml", "wb+") as outfile:
        outfile.write(infile)
except Exception as e:
    print(f"Couldn't save file: {e}")
