mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-12 15:48:21 +02:00
added get_github_file
This commit is contained in:
parent
66b66c145d
commit
1ab1a5d75b
1 changed files with 19 additions and 0 deletions
19
source/get_github_file.py
Normal file
19
source/get_github_file.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import requests
|
||||||
|
root = "https://raw.githubusercontent.com/Faraphel/MKWF-Install/master/"
|
||||||
|
|
||||||
|
|
||||||
|
def get_github_file(self, file):
|
||||||
|
try:
|
||||||
|
dl = requests.get(root+file, allow_redirects=True, stream=True)
|
||||||
|
if dl.status_code == 200: # if page is found
|
||||||
|
with open(file, "wb") as file:
|
||||||
|
chunk_size = 4096
|
||||||
|
for i, chunk in enumerate(dl.iter_content(chunk_size=chunk_size)):
|
||||||
|
file.write(chunk)
|
||||||
|
file.flush()
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
return -1
|
||||||
|
except:
|
||||||
|
self.log_error()
|
||||||
|
return -1
|
Loading…
Reference in a new issue