update synchronize/synchronize.py.
This commit is contained in:
parent
961eac36ff
commit
cb215942e5
@ -32,10 +32,14 @@ def log(logvar):
|
|||||||
def synchronize(url, filepath):
|
def synchronize(url, filepath):
|
||||||
global Log
|
global Log
|
||||||
log('[INFO]:The ' + SystemName + ' is synchronizing the file ' + SavePath + filepath + '.')
|
log('[INFO]:The ' + SystemName + ' is synchronizing the file ' + SavePath + filepath + '.')
|
||||||
synchronize=requests.get(url)
|
try:
|
||||||
with open(SavePath + filepath,"wb") as code:
|
synchronize=requests.get(url)
|
||||||
code.write(synchronize.content)
|
with open(SavePath + filepath,"wb") as code:
|
||||||
log('[INFO]:The file ' + SavePath + filepath + ' has been synchronized successfully.')
|
code.write(synchronize.content)
|
||||||
|
except:
|
||||||
|
log('[ERROR]:There has a error in task of synchronizing the file ' + SavePath + filepath + '.')
|
||||||
|
else:
|
||||||
|
log('[INFO]:The file ' + SavePath + filepath + ' has been synchronized successfully.')
|
||||||
#Module Which Be Used To Determine Whether The Dir Exists.
|
#Module Which Be Used To Determine Whether The Dir Exists.
|
||||||
def make_sure_dir_exists(dirpath):
|
def make_sure_dir_exists(dirpath):
|
||||||
global Log
|
global Log
|
||||||
@ -116,7 +120,6 @@ log('[INFO]:There has ' + str(mcversionsnumber) + ' MC versions in total .')
|
|||||||
log('[INFO]:Counting how many MC versions in total successfully.')
|
log('[INFO]:Counting how many MC versions in total successfully.')
|
||||||
#Starting To Synchronize More Files And Dirs.
|
#Starting To Synchronize More Files And Dirs.
|
||||||
#Auto Synchronize Files And Dirs on https://launchermeta.mojang.com/.
|
#Auto Synchronize Files And Dirs on https://launchermeta.mojang.com/.
|
||||||
'''
|
|
||||||
log('[INFO]:Starting to synchronize files and dirs on https://launchermeta.mojang.com/.')
|
log('[INFO]:Starting to synchronize files and dirs on https://launchermeta.mojang.com/.')
|
||||||
whiletimes=0#Set Var whiletimes To Avoid Error.
|
whiletimes=0#Set Var whiletimes To Avoid Error.
|
||||||
while(whiletimes < mcversionsnumber):
|
while(whiletimes < mcversionsnumber):
|
||||||
@ -133,7 +136,6 @@ while(whiletimes < mcversionsnumber):
|
|||||||
make_sure_dir_exists(filetosync)
|
make_sure_dir_exists(filetosync)
|
||||||
synchronize(onlineurlwithouthttps, fileurl)
|
synchronize(onlineurlwithouthttps, fileurl)
|
||||||
log('[INFO]:Synchronizing files and dirs on https://launchermeta.mojang.com/ successfully.')
|
log('[INFO]:Synchronizing files and dirs on https://launchermeta.mojang.com/ successfully.')
|
||||||
'''
|
|
||||||
#Auto Synchronize Files And Dirs on https://libraries.minecraft.net/.
|
#Auto Synchronize Files And Dirs on https://libraries.minecraft.net/.
|
||||||
log('[INFO]:Starting to synchronize files and dirs on https://libraries.minecraft.net/.')
|
log('[INFO]:Starting to synchronize files and dirs on https://libraries.minecraft.net/.')
|
||||||
#Part Of 'downloads'.
|
#Part Of 'downloads'.
|
||||||
@ -148,12 +150,17 @@ while(whiletimes < mcversionsnumber):
|
|||||||
onlineurlwithouthttps=onlineurl.replace('https://', 'http://')#Avoid Https Connetion Errors
|
onlineurlwithouthttps=onlineurl.replace('https://', 'http://')#Avoid Https Connetion Errors
|
||||||
log('[INFO]:Starting to get the json of MC libraries ' + onlineurl +' list.')
|
log('[INFO]:Starting to get the json of MC libraries ' + onlineurl +' list.')
|
||||||
#Save MC Libraries Json In Global Variables
|
#Save MC Libraries Json In Global Variables
|
||||||
mclibrariesjson=requests.get(url=onlineurlwithouthttps)
|
try:#Avoid Http/Httos Connection Errors Making Whole Synchronize Stop.
|
||||||
log('[INFO]:Get json of MC libraries ' + onlineurl +' successfully.')
|
mclibrariesjson=requests.get(url=onlineurlwithouthttps)
|
||||||
|
except:
|
||||||
|
log('[ERROR]:There has a error in task of getting json of MC libraries ' + onlineurl + '.')
|
||||||
|
else:
|
||||||
|
log('[INFO]:Get json of MC libraries ' + onlineurl + ' successfully.')
|
||||||
#Read Json Of MC Libraries.
|
#Read Json Of MC Libraries.
|
||||||
mclibrariesload=json.loads(mclibrariesjson.text)
|
mclibrariesload=json.loads(mclibrariesjson.text)
|
||||||
#Synchronize Files In "downloads".
|
#Synchronize Files In "downloads".
|
||||||
try:
|
log('[INFO]:Starting to synchronize files in ”downloads".')
|
||||||
|
try:#Avoid Http/Httos Connection Errors Or Synchronize Module Download Failed Errors Making Whole Synchronize Stop.
|
||||||
onlineurl2=mclibrariesload['downloads']['client']['url']
|
onlineurl2=mclibrariesload['downloads']['client']['url']
|
||||||
fileurl2='mojang/launcher/' + onlineurl2.replace('https://launcher.mojang.com/','')
|
fileurl2='mojang/launcher/' + onlineurl2.replace('https://launcher.mojang.com/','')
|
||||||
filetosync2=fileurl2[::-1].split('/', 1)[-1][::-1]
|
filetosync2=fileurl2[::-1].split('/', 1)[-1][::-1]
|
||||||
@ -181,9 +188,9 @@ while(whiletimes < mcversionsnumber):
|
|||||||
make_sure_dir_exists(filetosync2)
|
make_sure_dir_exists(filetosync2)
|
||||||
synchronize(onlineurl2, fileurl2)
|
synchronize(onlineurl2, fileurl2)
|
||||||
except:
|
except:
|
||||||
placeholder=''
|
log('[ERROR]:There has a error in task of synchronizing files in "downloads".')
|
||||||
finally:
|
else:
|
||||||
placeholder=''
|
log('[INFO]:Synchronizing files in "downloads" successfully.')
|
||||||
log('[INFO]:Starting to count how many MC libraries files in ' + onlineurl + ' in total.')
|
log('[INFO]:Starting to count how many MC libraries files in ' + onlineurl + ' in total.')
|
||||||
#Count How Many MC Libraries Files in total.
|
#Count How Many MC Libraries Files in total.
|
||||||
mclibrariesjsontext=mclibrariesjson.text
|
mclibrariesjsontext=mclibrariesjson.text
|
||||||
@ -195,8 +202,9 @@ while(whiletimes < mcversionsnumber):
|
|||||||
#Count While Times.
|
#Count While Times.
|
||||||
whiletimes3=whiletimes3 + 1
|
whiletimes3=whiletimes3 + 1
|
||||||
whiletimesload3=whiletimes3 - 1
|
whiletimesload3=whiletimes3 - 1
|
||||||
#Use 'try' To Avoid Out Of Range Errors.
|
#Synchronize Files In "libraries".
|
||||||
try:
|
log('[INFO]:Starting to synchronize Files In "libraries".')
|
||||||
|
try:#Avoid Http/Httos Connection Errors Or Synchronize Module Download Failed Errors Making Whole Synchronize Stop.
|
||||||
#Synchronize Files In "libraries/.../downloads/artifact".
|
#Synchronize Files In "libraries/.../downloads/artifact".
|
||||||
onlineurl3=mclibrariesload['libraries'][whiletimesload3]['downloads']['artifact']['url']
|
onlineurl3=mclibrariesload['libraries'][whiletimesload3]['downloads']['artifact']['url']
|
||||||
onlineurlwithouthttps3=onlineurl3.replace('https://', 'http://')
|
onlineurlwithouthttps3=onlineurl3.replace('https://', 'http://')
|
||||||
@ -204,12 +212,6 @@ while(whiletimes < mcversionsnumber):
|
|||||||
filetosync3=fileurl3[::-1].split('/', 1)[-1][::-1]
|
filetosync3=fileurl3[::-1].split('/', 1)[-1][::-1]
|
||||||
make_sure_dir_exists(filetosync3)
|
make_sure_dir_exists(filetosync3)
|
||||||
synchronize(onlineurlwithouthttps3, fileurl3)
|
synchronize(onlineurlwithouthttps3, fileurl3)
|
||||||
except:
|
|
||||||
placeholder=''
|
|
||||||
finally:
|
|
||||||
placeholder=''
|
|
||||||
#Use 'try' To Avoid Out Of Range Errors.
|
|
||||||
try:
|
|
||||||
#Synchronize Files In "libraries/.../downloads/classifiers/javadoc".
|
#Synchronize Files In "libraries/.../downloads/classifiers/javadoc".
|
||||||
onlineurl3=mclibrariesload['libraries'][whiletimesload3]['downloads']['classifiers']['javadoc']['url']
|
onlineurl3=mclibrariesload['libraries'][whiletimesload3]['downloads']['classifiers']['javadoc']['url']
|
||||||
onlineurlwithouthttps3=onlineurl3.replace('https://', 'http://')
|
onlineurlwithouthttps3=onlineurl3.replace('https://', 'http://')
|
||||||
@ -217,12 +219,6 @@ while(whiletimes < mcversionsnumber):
|
|||||||
filetosync3=fileurl3[::-1].split('/', 1)[-1][::-1]
|
filetosync3=fileurl3[::-1].split('/', 1)[-1][::-1]
|
||||||
make_sure_dir_exists(filetosync3)
|
make_sure_dir_exists(filetosync3)
|
||||||
synchronize(onlineurlwithouthttps3, fileurl3)
|
synchronize(onlineurlwithouthttps3, fileurl3)
|
||||||
except:
|
|
||||||
placeholder=''
|
|
||||||
finally:
|
|
||||||
placeholder=''
|
|
||||||
#Use 'try' To Avoid Out Of Range Errors.
|
|
||||||
try:
|
|
||||||
#Synchronize Files In "libraries/.../downloads/classifiers/natives-linux".
|
#Synchronize Files In "libraries/.../downloads/classifiers/natives-linux".
|
||||||
onlineurl3=mclibrariesload['libraries'][whiletimesload3]['downloads']['classifiers']['natives-linux']['url']
|
onlineurl3=mclibrariesload['libraries'][whiletimesload3]['downloads']['classifiers']['natives-linux']['url']
|
||||||
onlineurlwithouthttps3=onlineurl3.replace('https://', 'http://')
|
onlineurlwithouthttps3=onlineurl3.replace('https://', 'http://')
|
||||||
@ -230,12 +226,6 @@ while(whiletimes < mcversionsnumber):
|
|||||||
filetosync3=fileurl3[::-1].split('/', 1)[-1][::-1]
|
filetosync3=fileurl3[::-1].split('/', 1)[-1][::-1]
|
||||||
make_sure_dir_exists(filetosync3)
|
make_sure_dir_exists(filetosync3)
|
||||||
synchronize(onlineurlwithouthttps3, fileurl3)
|
synchronize(onlineurlwithouthttps3, fileurl3)
|
||||||
except:
|
|
||||||
placeholder=''
|
|
||||||
finally:
|
|
||||||
placeholder=''
|
|
||||||
#Use 'try' To Avoid Out Of Range Errors.
|
|
||||||
try:
|
|
||||||
#Synchronize Files In "libraries/.../downloads/classifiers/natives-macos".
|
#Synchronize Files In "libraries/.../downloads/classifiers/natives-macos".
|
||||||
onlineurl3=mclibrariesload['libraries'][whiletimesload3]['downloads']['classifiers']['natives-macos']['url']
|
onlineurl3=mclibrariesload['libraries'][whiletimesload3]['downloads']['classifiers']['natives-macos']['url']
|
||||||
onlineurlwithouthttps3=onlineurl3.replace('https://', 'http://')
|
onlineurlwithouthttps3=onlineurl3.replace('https://', 'http://')
|
||||||
@ -243,12 +233,6 @@ while(whiletimes < mcversionsnumber):
|
|||||||
filetosync3=fileurl3[::-1].split('/', 1)[-1][::-1]
|
filetosync3=fileurl3[::-1].split('/', 1)[-1][::-1]
|
||||||
make_sure_dir_exists(filetosync3)
|
make_sure_dir_exists(filetosync3)
|
||||||
synchronize(onlineurlwithouthttps3, fileurl3)
|
synchronize(onlineurlwithouthttps3, fileurl3)
|
||||||
except:
|
|
||||||
placeholder=''
|
|
||||||
finally:
|
|
||||||
placeholder=''
|
|
||||||
#Use 'try' To Avoid Out Of Range Errors.
|
|
||||||
try:
|
|
||||||
#Synchronize Files In "libraries/.../downloads/classifiers/natives-windows".
|
#Synchronize Files In "libraries/.../downloads/classifiers/natives-windows".
|
||||||
onlineurl3=mclibrariesload['libraries'][whiletimesload3]['downloads']['classifiers']['natives-windows']['url']
|
onlineurl3=mclibrariesload['libraries'][whiletimesload3]['downloads']['classifiers']['natives-windows']['url']
|
||||||
onlineurlwithouthttps3=onlineurl3.replace('https://', 'http://')
|
onlineurlwithouthttps3=onlineurl3.replace('https://', 'http://')
|
||||||
@ -256,12 +240,6 @@ while(whiletimes < mcversionsnumber):
|
|||||||
filetosync3=fileurl3[::-1].split('/', 1)[-1][::-1]
|
filetosync3=fileurl3[::-1].split('/', 1)[-1][::-1]
|
||||||
make_sure_dir_exists(filetosync3)
|
make_sure_dir_exists(filetosync3)
|
||||||
synchronize(onlineurlwithouthttps3, fileurl3)
|
synchronize(onlineurlwithouthttps3, fileurl3)
|
||||||
except:
|
|
||||||
placeholder=''
|
|
||||||
finally:
|
|
||||||
placeholder=''
|
|
||||||
#Use 'try' To Avoid Out Of Range Errors.
|
|
||||||
try:
|
|
||||||
#Synchronize Files In "libraries/.../downloads/artifact/classifiers/sources".
|
#Synchronize Files In "libraries/.../downloads/artifact/classifiers/sources".
|
||||||
onlineurl3=mclibrariesload['libraries'][whiletimesload3]['downloads']['classifiers']['sources']['url']
|
onlineurl3=mclibrariesload['libraries'][whiletimesload3]['downloads']['classifiers']['sources']['url']
|
||||||
onlineurlwithouthttps3=onlineurl3.replace('https://', 'http://')
|
onlineurlwithouthttps3=onlineurl3.replace('https://', 'http://')
|
||||||
@ -270,9 +248,9 @@ while(whiletimes < mcversionsnumber):
|
|||||||
make_sure_dir_exists(filetosync3)
|
make_sure_dir_exists(filetosync3)
|
||||||
synchronize(onlineurlwithouthttps3, fileurl3)
|
synchronize(onlineurlwithouthttps3, fileurl3)
|
||||||
except:
|
except:
|
||||||
placeholder=''
|
log('[ERROR]:There has a error in task of synchronizing files in ”libraries".')
|
||||||
finally:
|
else:
|
||||||
placeholder=''
|
log('[INFO]:Synchronizing files in "libraries" successfully.')
|
||||||
|
|
||||||
log('[INFO]:Synchronizing files and dirs on https://libraries.minecraft.net/ successfully.')
|
log('[INFO]:Synchronizing files and dirs on https://libraries.minecraft.net/ successfully.')
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user