Browse Source

업데이트 'download_sample.py'

Hio-Been Han 3 years ago
parent
commit
5ec9f1f935
1 changed files with 5 additions and 3 deletions
  1. 5 3
      download_sample.py

+ 5 - 3
download_sample.py

@@ -1,13 +1,14 @@
 # Demo 1-1. Setting an enviroment
 from os import listdir, mkdir, path, system, getcwd
+import warnings; warnings.simplefilter("ignore")
 dir_origin = dir_origin = getcwd()+'/' # <- Change this in local machine
 dir_dataset= 'dataset/'
 print('\n1============ Start Downloading =================\n')
 print('Target directory ... => [%s%s]'%(dir_origin,dir_dataset))
 
 #!rm -rf /content/dataset/
-import requests
-def download( dataset_to_download = range(1,7), dir_dataset = dir_dataset ):
+import requests, time
+def download_dataset( dataset_to_download = range(1,7), dir_dataset = dir_dataset ):
   # Check directory
   if not path.isdir('%s%s'%(dir_origin,dir_dataset)):
     mkdir('%s%s'%(dir_origin,dir_dataset))
@@ -32,11 +33,12 @@ def download( dataset_to_download = range(1,7), dir_dataset = dir_dataset ):
               if block: file.write(block)
     else:
       print('...skipping already existing file [%s]...'%fname_dest)
+    time.sleep(1)
 
 # Initiate downloading
 dataset_to_download = [2] # Partial download to prevent long download time
 #dataset_to_download = [1,2,3,4,5,6] # Download of whole dataset
-download(dataset_to_download)
+download_dataset(dataset_to_download)
 print('\n============= Download finished ==================\n\n')
 
 # List up 'dataset/' directory