Update try_download.py
This commit is contained in:
		
							parent
							
								
									a1a723020b
								
							
						
					
					
						commit
						3a0a65377a
					
				| @ -6,7 +6,7 @@ def tqdm_request(url,dir_to,file,desc): | |||||||
|     ''' |     ''' | ||||||
|     Try to download files from a remote server by request. |     Try to download files from a remote server by request. | ||||||
|     ''' |     ''' | ||||||
|     block_size = 1024 |     block_size = 1024*10 | ||||||
|     bar_format = "{l_bar}%s{bar}%s{r_bar}" % (Fore.BLUE, Fore.RESET) |     bar_format = "{l_bar}%s{bar}%s{r_bar}" % (Fore.BLUE, Fore.RESET) | ||||||
|     for idownload in range(5): |     for idownload in range(5): | ||||||
|         try: |         try: | ||||||
| @ -19,6 +19,8 @@ def tqdm_request(url,dir_to,file,desc): | |||||||
|             for chunk in res.iter_content(block_size): |             for chunk in res.iter_content(block_size): | ||||||
|                 pbar.update(len(chunk)) |                 pbar.update(len(chunk)) | ||||||
|                 local_file.write(chunk)   |                 local_file.write(chunk)   | ||||||
|  |             pbar.close()   | ||||||
|  |             res.close()   | ||||||
|             break |             break | ||||||
|         except:  |         except:  | ||||||
|             sleep(2) |             sleep(2) | ||||||
| @ -26,7 +28,5 @@ def tqdm_request(url,dir_to,file,desc): | |||||||
|                 remove(dir_to + file) |                 remove(dir_to + file) | ||||||
|                 print('No response, skip this file.')  |                 print('No response, skip this file.')  | ||||||
|         finally:     |         finally:     | ||||||
|             pbar.close()     |  | ||||||
|             local_file.close()  |             local_file.close()  | ||||||
|             res.close()   |  | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user