DreamSunny commited on
Commit
c137180
1 Parent(s): 0685cb0

update func

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -13,18 +13,19 @@ import gc
13
  def Gitclone(URI:str,ClonePath:pathlib.Path ) -> int :
14
  if pathlib.Path.exists(ClonePath):
15
  return 0
16
- while True:
17
  i=subprocess.run([r"git",r"clone",str(URI),str(ClonePath)])
18
  if(i.returncode == 0 ):
19
  del i
20
- gc.collect()
21
  return 0
22
  else :
23
  del i
 
 
24
 
25
  def DownLoad(URI:str,DownloadPath:pathlib.Path,DownLoadFileName:str ) -> int:
26
  if (DownloadPath / DownLoadFileName).is_file(): return 0
27
- while (True):
28
  i=subprocess.run([r"aria2c",r"-c",r"-x" ,r"16", r"-s",r"16", r"-k" ,r"1M" ,r"-m",r"0",r"--enable-mmap=false",r"--console-log-level=error",r"-d",str(DownloadPath),r"-o",DownLoadFileName,URI]);
29
  if(i.returncode == 0 ):
30
  del i
@@ -32,6 +33,7 @@ def DownLoad(URI:str,DownloadPath:pathlib.Path,DownLoadFileName:str ) -> int:
32
  return 0
33
  else :
34
  del i
 
35
 
36
  user_home =pathlib.Path.home().resolve()
37
  os.chdir(str(user_home))
 
13
  def Gitclone(URI:str,ClonePath:pathlib.Path ) -> int :
14
  if pathlib.Path.exists(ClonePath):
15
  return 0
16
+ for z in range(10):
17
  i=subprocess.run([r"git",r"clone",str(URI),str(ClonePath)])
18
  if(i.returncode == 0 ):
19
  del i
 
20
  return 0
21
  else :
22
  del i
23
+ raise Exception(str.format("clone \'{0}\' failed",URI))
24
+
25
 
26
  def DownLoad(URI:str,DownloadPath:pathlib.Path,DownLoadFileName:str ) -> int:
27
  if (DownloadPath / DownLoadFileName).is_file(): return 0
28
+ for z in range(10):
29
  i=subprocess.run([r"aria2c",r"-c",r"-x" ,r"16", r"-s",r"16", r"-k" ,r"1M" ,r"-m",r"0",r"--enable-mmap=false",r"--console-log-level=error",r"-d",str(DownloadPath),r"-o",DownLoadFileName,URI]);
30
  if(i.returncode == 0 ):
31
  del i
 
33
  return 0
34
  else :
35
  del i
36
+ raise Exception(str.format("download \'{0}\' failed",URI))
37
 
38
  user_home =pathlib.Path.home().resolve()
39
  os.chdir(str(user_home))