added code for updated file

This commit is contained in:
raphael60650 2021-06-18 16:55:21 +02:00
parent 45071bb469
commit d91a4c9241

View file

@ -6,12 +6,13 @@ root = "https://raw.githubusercontent.com/Faraphel/MKWF-Install/master/"
def get_github_file(self, file): def get_github_file(self, file):
try: try:
returncode = 0
if self.boolvar_disable_download.get(): return 2 if self.boolvar_disable_download.get(): return 2
dl = requests.get(root+file, allow_redirects=True, stream=True) dl = requests.get(root+file, allow_redirects=True, stream=True)
if os.path.exists(file): if os.path.exists(file):
if int(dl.headers['Content-Length']) == os.path.getsize(file): if int(dl.headers['Content-Length']) == os.path.getsize(file): return 1
return 1 else: returncode = 3
if dl.status_code == 200: # if page is found if dl.status_code == 200: # if page is found
with open(file, "wb") as file: with open(file, "wb") as file:
@ -19,7 +20,7 @@ def get_github_file(self, file):
for i, chunk in enumerate(dl.iter_content(chunk_size=chunk_size)): for i, chunk in enumerate(dl.iter_content(chunk_size=chunk_size)):
file.write(chunk) file.write(chunk)
file.flush() file.flush()
return 0 return returncode
else: else:
print(f"error {dl.status_code} {file}") print(f"error {dl.status_code} {file}")
return -1 return -1