File tree Expand file tree Collapse file tree 1 file changed +20
-16
lines changed Expand file tree Collapse file tree 1 file changed +20
-16
lines changed Original file line number Diff line number Diff line change @@ -682,20 +682,21 @@ def download_with_curl(url, file_name):
682682
683683def download_with_urllib (url , file_name ):
684684 u = urlopen (url )
685+ file_size = get_content_length (u )
686+ if file_size > 0 :
687+ print ("Downloading: %s from %s, %s Bytes" % (file_name , url , file_size ))
688+ else :
689+ print ("Downloading: %s from %s" % (file_name , url ))
690+
691+ file_size_dl = 0
692+ # Draw a progress bar 80 chars wide (in non-TTY mode)
693+ progress_max = 80 - 4
694+ progress_shown = 0
695+ block_sz = 256 * 1024
696+ if not TTY_OUTPUT :
697+ print (' [' , end = '' )
698+
685699 with open (file_name , 'wb' ) as f :
686- file_size = get_content_length (u )
687- if file_size > 0 :
688- print ("Downloading: %s from %s, %s Bytes" % (file_name , url , file_size ))
689- else :
690- print ("Downloading: %s from %s" % (file_name , url ))
691-
692- file_size_dl = 0
693- # Draw a progress bar 80 chars wide (in non-TTY mode)
694- progress_max = 80 - 4
695- progress_shown = 0
696- block_sz = 256 * 1024
697- if not TTY_OUTPUT :
698- print (' [' , end = '' )
699700 while True :
700701 buffer = u .read (block_sz )
701702 if not buffer :
@@ -713,9 +714,12 @@ def download_with_urllib(url, file_name):
713714 print ('-' , end = '' )
714715 sys .stdout .flush ()
715716 progress_shown += 1
716- if not TTY_OUTPUT :
717- print (']' )
718- sys .stdout .flush ()
717+
718+ if not TTY_OUTPUT :
719+ print (']' )
720+ sys .stdout .flush ()
721+
722+ debug_print ('finished downloading (%d bytes)' % file_size_dl )
719723
720724
721725# On success, returns the filename on the disk pointing to the destination file that was produced
You can’t perform that action at this time.
0 commit comments