@@ -33,17 +33,14 @@ def unpack(archive_fn, path, pkg, pkgs_name_in_json):
3333
3434 flag = True
3535
36- #print(pkg)
37-
3836 if ".tar.bz2" in archive_fn :
3937 arch = tarfile .open (archive_fn , "r:bz2" )
4038 for tarinfo in arch :
4139 arch .extract (tarinfo , path )
4240 a = tarinfo .name
4341 if not os .path .isdir (os .path .join (path , a )):
4442 right_path = a .replace ('/' , '\\ ' )
45- a = os .path .join (os .path .split (right_path )[
46- 0 ], os .path .split (right_path )[1 ])
43+ a = os .path .join (os .path .split (right_path )[0 ], os .path .split (right_path )[1 ])
4744 pkgsdb .savetodb (a , archive_fn )
4845 arch .close ()
4946
@@ -54,8 +51,7 @@ def unpack(archive_fn, path, pkg, pkgs_name_in_json):
5451 a = tarinfo .name
5552 if not os .path .isdir (os .path .join (path , a )):
5653 right_path = a .replace ('/' , '\\ ' )
57- a = os .path .join (os .path .split (right_path )[
58- 0 ], os .path .split (right_path )[1 ])
54+ a = os .path .join (os .path .split (right_path )[0 ], os .path .split (right_path )[1 ])
5955 pkgsdb .savetodb (a , archive_fn )
6056 arch .close ()
6157
@@ -71,19 +67,14 @@ def unpack(archive_fn, path, pkg, pkgs_name_in_json):
7167 change_dirname = pkgs_name_in_json + '-' + pkg ['ver' ]
7268 flag = False
7369
74- right_name_to_db = right_path .replace (
75- dir_name , change_dirname , 1 )
76- #print(right_name_to_db)
70+ right_name_to_db = right_path .replace (dir_name , change_dirname , 1 )
7771 pkgsdb .savetodb (right_name_to_db , archive_fn , right_path )
7872 arch .close ()
7973
80- #Change the folder name
74+ # Change the folder name
8175
8276 change_dirname = pkgs_name_in_json + '-' + pkg ['ver' ]
83- #print(os.path.join(path, dir_name))
84- #print(os.path.join(path, change_dirname))
85- #print(pkgs_name_in_json)
86-
77+
8778 if os .path .isdir (os .path .join (path , change_dirname )):
8879 cmd = 'rd /s /q ' + os .path .join (path , change_dirname )
8980 os .system (cmd )
@@ -96,28 +87,32 @@ def packtest(path):
9687 if ".zip" in path :
9788 try :
9889 if zipfile .is_zipfile (path ):
99- # test zip again to make sure it's a right zip file.
90+ # Test zip again to make sure it's a right zip file.
10091 arch = zipfile .ZipFile (path , "r" )
10192 if arch .testzip ():
10293 ret = False
103- arch .close ()
94+ arch .close ()
95+ else :
96+ ret = False
97+ print ('package check error. \n ' )
10498 except Exception , e :
105- print ('e.message:%s\t ' % e .message )
106- arch .close ()
99+ print ('packtest e.message:%s\t ' % e .message )
100+ # arch.close()
101+ print ("The archive package is broken. \n " )
107102 ret = False
108-
103+
109104 if ".tar.bz2" in path :
110105 try :
111106 if not tarfile .is_tarfile (path ):
112- ret = False
107+ ret = False
113108 except Exception , e :
114109 ret = False
115110
116111 if ".tar.gz" in path :
117112 try :
118113 if not tarfile .is_tarfile (path ):
119- ret = False
114+ ret = False
120115 except Exception , e :
121116 ret = False
122-
117+
123118 return ret
0 commit comments