@@ -87,7 +87,7 @@ def install(self):
87
87
else :
88
88
repo .remotes .origin .pull ()
89
89
print (f"\t git pull latest: { repo .head .object .hexsha } " )
90
-
90
+
91
91
# Download
92
92
else :
93
93
filename = self ._slugify (os .path .basename (src ))
@@ -151,20 +151,20 @@ def _download_file(self, src, install_to, name, bearer_token = None):
151
151
headers ['Authorization' ] = f'Bearer { bearer_token } '
152
152
response = requests .get (src , stream = True , allow_redirects = True , headers = headers )
153
153
response .raise_for_status ()
154
-
154
+
155
155
# Get the filename from the Content-Disposition header
156
156
content_disposition = response .headers .get ('Content-Disposition' )
157
157
if content_disposition :
158
158
filename = re .findall ("filename=(.+)" , content_disposition )[0 ].strip ('"' )
159
159
else :
160
160
filename = name
161
-
161
+
162
162
# Sanitize the filename
163
163
filename = self ._slugify (filename )
164
-
164
+
165
165
# Construct the full path for the file
166
166
file_path = os .path .join (install_to , filename )
167
-
167
+
168
168
# Download the file with progress bar
169
169
total_size = int (response .headers .get ('content-length' , 0 ))
170
170
with open (file_path , 'wb' ) as file , tqdm (
@@ -177,10 +177,10 @@ def _download_file(self, src, install_to, name, bearer_token = None):
177
177
for data in response .iter_content (chunk_size = 1024 ):
178
178
size = file .write (data )
179
179
progress_bar .update (size )
180
-
180
+
181
181
print (f"\t Downloaded: { file_path } " )
182
182
print (f"\t Size: { self ._get_file_size (file_path )} " )
183
-
183
+
184
184
return file_path
185
185
except requests .exceptions .RequestException as e :
186
186
print (f"\t ❌ Error downloading file: { e } " )
@@ -214,7 +214,7 @@ def main():
214
214
parser = argparse .ArgumentParser (description = "Install models, git repos and run scripts defined in the zoo.yaml file." )
215
215
parser .add_argument ("command" , nargs = "?" , choices = ["install" , "run" ], help = "The command to execute." )
216
216
parser .add_argument ("script" , nargs = "?" , help = "The script name to execute." )
217
- parser .add_argument ("-v" , "--version" , action = "version" , help = "The current version of the zoomaker." , version = "0.8 .0" )
217
+ parser .add_argument ("-v" , "--version" , action = "version" , help = "The current version of the zoomaker." , version = "0.9 .0" )
218
218
args = parser .parse_args ()
219
219
220
220
if args .command == "install" :
@@ -225,4 +225,4 @@ def main():
225
225
parser .print_help ()
226
226
227
227
if __name__ == "__main__" :
228
- main ()
228
+ main ()
0 commit comments