@@ -31,40 +31,26 @@ def getpackages(folder):
3131 archives = []
3232 for package in packages :
3333 print (package )
34- count = 10
35- while count > 0 :
36- filename = None
37- path = FTPPATH + folder + '/' + package
38- try :
39- time .sleep (0.01 )
40- files = f .nlst (path )
41-
42- for s in files :
43- if s .find ('.orig.tar.' ) > 0 :
44- filename = s
45-
46- if not filename :
47- for s in files :
48- if s .find ('.tar.' ) > 0 :
49- filename = s
50-
51- except socket .error as err :
52- print (str (err ))
53- except ftplib .error_temp as err :
54- print (str (err ))
55- except EOFError as err :
56- print (str (err ))
57-
58- if not filename :
59- print ('Retry..' )
60- f .close ()
61- time .sleep (1 )
62- f = ftplib .FTP (FTPSERVER )
63- f .login ()
64- count = count - 1
65- else :
66- archives .append (package + '/' + filename )
67- count = 0
34+ filename = None
35+ path = FTPPATH + folder + '/' + package
36+
37+ time .sleep (1 )
38+ files = f .nlst (path )
39+
40+ for s in files :
41+ if s .find ('.orig.tar.' ) > 0 :
42+ filename = s
43+
44+ if not filename :
45+ for s in files :
46+ if s .find ('.tar.' ) > 0 :
47+ filename = s
48+
49+ if not filename :
50+ archives = []
51+ return archives
52+
53+ archives .append (package + '/' + filename )
6854
6955 return archives
7056
@@ -131,7 +117,12 @@ def scanarchive(fullpath):
131117 results .close ()
132118
133119 filename = fullpath [fullpath .rfind ('/' ) + 1 :]
134- subprocess .call (['wget' , fullpath ])
120+ subprocess .call (['nice' , 'wget' , fullpath ])
121+ if not os .path .isfile (filename ):
122+ removeAllExceptResults ()
123+ os .remove (filename )
124+ sys .exit (1 )
125+
135126 if filename [- 3 :] == '.gz' :
136127 subprocess .call (['tar' , 'xzvf' , filename ])
137128 elif filename [- 3 :] == '.xz' :
@@ -183,6 +174,9 @@ def scanarchive(fullpath):
183174 sys .exit (1 )
184175
185176archives = getpackages (FOLDER )
177+ if len (archives ) == 0 :
178+ print ('failed to load packages' )
179+ sys .exit (1 )
186180
187181time .sleep (30 )
188182
0 commit comments