@@ -38,7 +38,7 @@ def download_unpack_zip(zip_name, output_path, zip_path,
3838 Download and unpack one zip file
3939 """
4040
41- digit_match = re .search (r'\d.zip$' , zip_name ) # if we have multi archive
41+ digit_match = re .search (r'fcn \d.zip$' , zip_name ) # if we have multi archive
4242 if digit_match :
4343 name = zip_name [:- 5 ] # cut last character with number
4444 else :
@@ -54,7 +54,7 @@ def download_unpack_zip(zip_name, output_path, zip_path,
5454 else :
5555 print ("[INFO] Skip downloading {}. Model already exists here {}" .
5656 format (zip_name , model_out_folder ))
57- return False
57+ return True
5858
5959 file_name_url = git_hub_repo_url + '/' + zip_name
6060 file_name_zip = zip_path / zip_name
@@ -65,13 +65,24 @@ def download_unpack_zip(zip_name, output_path, zip_path,
6565 print (" [ERROR]. Can not access to Zip file by address {}" .
6666 format (file_name_url ))
6767 return False
68+ try :
69+ with requests .get (file_name_url , stream = True ) as r_zip_file :
70+ with open (file_name_zip , 'wb' ) as f_download :
71+ shutil .copyfileobj (r_zip_file .raw , f_download )
72+ except Exception as error :
73+ print (" [ERROR]. Can not download to file by address {}"
74+ " Reason: {}" .
75+ format (file_name_url , error ))
76+ return False
6877
69- with requests .get (file_name_url , stream = True ) as r_zip_file :
70- with open (file_name_zip , 'wb' ) as f_download :
71- shutil .copyfileobj (r_zip_file .raw , f_download )
72-
73- with zipfile .ZipFile (file_name_zip , 'r' ) as zip_ref :
74- zip_ref .extractall (output_path )
78+ try :
79+ with zipfile .ZipFile (file_name_zip , 'r' ) as zip_ref :
80+ zip_ref .extractall (output_path )
81+ except Exception as error :
82+ print (" [ERROR]. Can not unpack {}"
83+ " Reason: {}" .
84+ format (file_name_zip , error ))
85+ return False
7586
7687 print ("[INFO] {} is downloaded and unpacked"
7788 .format (zip_name ))
@@ -94,8 +105,7 @@ def arg2bool(bool_arg):
94105
95106
96107def main ():
97- git_hub_repo_url = 'https://github.com/foss-for-synopsys-dwc-arc-processors/synopsys-caffe-models/raw/master/caffe_models_zipped'
98-
108+ git_hub_repo_url = 'https://github.com/foss-for-synopsys-dwc-arc-processors/synopsys-caffe-models/raw/master/archived_models/models'
99109 parser = argparse .ArgumentParser ()
100110
101111 parser .add_argument (
@@ -166,10 +176,10 @@ def main():
166176 zip_path = output_path / "download" # folder for downloaded zip files
167177 try :
168178 zip_path .mkdir (parents = True , exist_ok = True )
169- except :
179+ except Exception as error :
170180 print (
171181 "[ERROR]. Problem of creating folder to download zipped CNN Models:"
172- " {}" .format (zip_path ))
182+ " Reason {}" .format (zip_path , error ))
173183 exit (1 )
174184
175185 print ("[INFO] NN Models path is {}" .format (output_path ))
0 commit comments