-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdater.py
32 lines (29 loc) · 1.15 KB
/
updater.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
import requests
from zipfile import ZipFile
import os
def update(url,structura_version, lookup_verison):
initial_check = requests.get(url,headers={"structuraVersion": structura_version,"lookupVersion":lookup_verison}).json()
print(initial_check)
updated=False
if initial_check["info"] == 'Update Availible':
print('Update Availible')
print(initial_check["url"])
response = requests.get(initial_check["url"], allow_redirects=True,stream=True)
if response.headers.get('content-type') == "application/xml":
print(response.content)
else:
with open("lookup_temp.zip","wb") as file:
file.write(response.content)
print("download completed")
with ZipFile("lookup_temp.zip", 'r') as zObject:
zObject.extractall(path="")
os.remove("lookup_temp.zip")
print("update complete")
updated=True
else:
print("up to date")
return updated
if __name__ =="__main__":
update("https://smgafwso25.execute-api.us-east-2.amazonaws.com/default/structuraUpdate",
"Structura1-6",
"none")