def ShowResults(newlist,num_files,target,output):
print "Files in the target "+target+" are:\n"
print "Files indexed:", len (urls_final)
for i in urls_final:
if i not in newlist:
newlist.append(i)
print i
#verify if the user wants to export results
if output == 'Y':
#Only it can enter if -j is put in the execution
ExportResults(newlist)
#Call to function to download the files
Downloadfiles(newlist,output)
#MAIN
python类download()的实例源码
def Downloadfiles(urls_metadata,output):
try:
print "\nDo you like downloading these files to analyze metadata(Y/N)?"
#Convert to lower the input
resp = raw_input().lower()
if (resp == 'n'):
print "Exiting"
exit(1)
if ((resp != 'y') and (resp != 'n')):
print "The option is not valided. Please, try again it"
if (resp =='y'):
print "Indicate the location where you want to keep the files downloaded",
path = raw_input()
try:
for url in urls_metadata:
try:
filename = wget.download(url,path)
Analyze_Metadata(filename)
except:
pass
Display_Export_Metadata(metadata_files,output)
except:
pass
except Exception as e:
print str(e)
#********************************************************#
#Definition and treatment of the parameters
def ShowResults(newlist,num_files,target,output):
print "Files in the target "+target+" are:\n"
print "Files indexed:", len (urls_final)
for i in urls_final:
if i not in newlist:
newlist.append(i)
print i
#verify if the user wants to export results
if output == 'Y':
#Only it can enter if -j is put in the execution
ExportResults(newlist)
#Call to function to download the files
Downloadfiles(newlist,output)
#MAIN
def ShowResults(newlist,num_files,target,output,option,captcha):
if option == 1:
print "Files into the target "+target+" are:\n"
if captcha == False:
print "Files indexed:", len (url_google)
for i in url_google:
#if i not in url_google:
newlist.append(i)
print i
else: ##Catpcha == True, try results of Bing
print "Files indexed:", len (urls_final)
for i in urls_final:
#if i not in url_google:
newlist.append(i)
print i
else:
#option ==2
print "ShowResults outside target"
print "Files outside target "+target+" are:\n"
print "Files indexed:", len (url_google)
for i in url_google:
#if i not in url_google:
newlist.append(i)
print i
#verify if the user wants to export results
if (output == 'Y') or (output =='y'):
#Only it can enter if -j is put in the execution
ExportResults(newlist)
#Call to function to download the files
Downloadfiles(newlist,output)
#MAIN
def Downloadfiles(urls_metadata,output,target):
path = None
try:
filename = None
print "\nDo you like downloading these files to analyze metadata(Y/N)?"
#Convert to lower the input
resp = raw_input().lower()
if (resp == 'n'):
print "Exiting"
exit(1)
if ((resp != 'y') and (resp != 'n')):
print "The option is not valided. Please, try again it"
if (resp =='y'):
print "Indicate the location where you want to keep the files downloaded.by default in the target folder",
path = raw_input()
#path = createdir.CreateDir(target)
for url in urls_metadata:
filename = wget.download(url,str(path))
Analyze_Metadata(filename)
Display_Export_Metadata(metadata_files,output,target)
if count_pdf > 1:
os.system('mv *pdf '+ str(target))
if count_word > 1:
os.system('mv *doc '+ str(target))
os.system('mv *docx '+ str(target))
if count_others > 1:
os.system('mv *xlsx '+ str(target))
os.system('mv *ppt '+ str(target))
except Exception as e:
print str(e)
def ShowResults(newlist,num_files,target):
print "Files in the target "+target+" are:\n"
print "Files indexed:", len (urls_final)
for i in urls_final:
if i not in newlist:
newlist.append(i)
print i
#verify if the user wants to export results
if output == 'Y':
#Only it can enter if -j is put in the execution
ExportResults(newlist)
#Call to function to download the files
Downloadfiles(newlist)
#MAIN
def ShowResults(newlist,num_files,target):
print "Files in the target "+target+" are:\n"
print "Files indexed:", len (urls_final)
for i in urls_final:
if i not in newlist:
newlist.append(i)
print i
#verify if the user wants to export results
if output == 'Y':
#Only it can enter if -j is put in the execution
ExportResults(newlist)
#Call to function to download the files
Downloadfiles(newlist)
#INICIO MAIN
def Downloadfiles(urls_metadata,output):
try:
print "\nDo you like downloading these files to analyze metadata(Y/N)?"
#Convert to lower the input
resp = raw_input().lower()
if (resp == 'n'):
print "Exiting"
exit(1)
if ((resp != 'y') and (resp != 'n')):
print "The option is not valided. Please, try again it"
if (resp =='y'):
print "Indicate the location where you want to keep the files downloaded",
path = raw_input()
try:
for url in urls_metadata:
try:
filename = wget.download(url,path)
Analyze_Metadata(filename)
except:
pass
Display_Export_Metadata(metadata_files,output)
except:
pass
except Exception as e:
print str(e)
#********************************************************#
#Definition and treatment of the parameters
def ShowResults(newlist,num_files,target,output):
print "Files in the target "+target+" are:\n"
print "Files indexed:", len (urls_final)
for i in urls_final:
if i not in newlist:
newlist.append(i)
print i
#verify if the user wants to export results
if output == 'Y':
#Only it can enter if -j is put in the execution
ExportResults(newlist)
#Call to function to download the files
Downloadfiles(newlist,output)
#MAIN
def Downloadfiles(urls_metadata,output):
try:
print "\nDo you like downloading these files to analyze metadata(Y/N)?"
#Convert to lower the input
resp = raw_input().lower()
if (resp == 'n'):
print "Exiting"
exit(1)
if ((resp != 'y') and (resp != 'n')):
print "The option is not valided. Please, try again it"
if (resp =='y'):
print "Indicate the location where you want to keep the files downloaded",
path = raw_input()
try:
for url in urls_metadata:
try:
filename = wget.download(url,path)
Analyze_Metadata(filename)
except:
pass
Display_Export_Metadata(metadata_files,output)
except:
pass
except Exception as e:
print str(e)
#********************************************************#
#Definition and treatment of the parameters
def Downloadfiles(urls_metadata,output):
try:
print "\nDo you like downloading these files to analyze metadata(Y/N)?"
#Convert to lower the input
resp = raw_input().lower()
if (resp == 'n'):
print "Exiting"
exit(1)
if ((resp != 'y') and (resp != 'n')):
print "The option is not valided. Please, try again it"
if (resp =='y'):
print "Indicate the location where you want to keep the files downloaded",
path = raw_input()
try:
for url in urls_metadata:
try:
filename = wget.download(url,path)
Analyze_Metadata(filename)
except:
pass
Display_Export_Metadata(metadata_files,output)
except:
pass
except Exception as e:
print str(e)
#********************************************************#
#Definition and treatment of the parameters
def ShowResults(newlist,num_files,target,output,option,captcha):
if option == 1:
print "Files into the target "+target+" are:\n"
if captcha == False:
print "Files indexed:", len (url_google)
for i in url_google:
#if i not in url_google:
newlist.append(i)
print i
else: ##Catpcha == True, try results of Bing
print "Files indexed:", len (urls_final)
for i in urls_final:
#if i not in url_google:
newlist.append(i)
print i
else:
#option ==2
print "ShowResults outside target"
print "Files outside target "+target+" are:\n"
print "Files indexed:", len (url_google)
for i in url_google:
#if i not in url_google:
newlist.append(i)
print i
#verify if the user wants to export results
if (output == 'Y') or (output =='y'):
#Only it can enter if -j is put in the execution
ExportResults(newlist)
#Call to function to download the files
Downloadfiles(newlist,output)
#MAIN
def load(self):
""" Load a dataset.
If a dataset has not been downloaded yet, this class downloads it.
"""
# download a dataset if needed.
self._download()
# load joints.
self.joints = self._load_joints()
def _download(self):
# download when file doesn't exist.
path = os.path.join(self.path, self.name)
if not os.path.isdir(path):
# download a dataset.
path = wget.download(self.url, self.path)
# extract the dataset.
with zipfile.ZipFile(path, 'r') as zip_file:
zip_file.extractall(self._get_extract_path())
# remove downloaded zip file.
os.remove(path)
def upload_remote_image(self, cdn_path, url):
"""Upload remote image to CDN.
Args:
cdn_path: the name of file storing in CDN
url: the remote image URL
Returns:
return whether it's uploaded.
"""
file_path = wget.download(url)
result = self.upload_local_image(cdn_path, file_path)
os.remove(file_path)
return result
insert_other_items_in_sql_database.py 文件源码
项目:sql_python_deep_learning
作者: Azure
项目源码
文件源码
阅读 24
收藏 0
点赞 0
评论 0
def maybe_download_model(filename='ResNet_18.model'):
if(os.path.isfile(filename)):
print('Model %s already downloaded' % filename)
else:
model_name_to_url = {
'ResNet_18.model': 'http://migonzastorage.blob.core.windows.net/deep-learning/models/cntk/rc3/ResNet_18.model',
'ResNet_152.model': 'http://migonzastorage.blob.core.windows.net/deep-learning/models/cntk/rc3/ResNet_152.model'
}
url = model_name_to_url[filename]
wget.download(url)
def download_dstc2_data():
if not os.path.isfile('./tmp/dstc2_traindev.tar.gz'):
wget.download('http://camdial.org/~mh521/dstc/downloads/dstc2_traindev.tar.gz', './tmp')
wget.download('http://camdial.org/~mh521/dstc/downloads/dstc2_test.tar.gz', './tmp')
wget.download('http://camdial.org/~mh521/dstc/downloads/dstc2_scripts.tar.gz', './tmp')
print()
else:
print('Everything appears to be downloaded.')
def download(files, delay=0, prefix=file_prefix, convert=False):
# Given a list of files, downloads each, optionally also converts to csv
total = len(files)
i = 1
for file in files:
filename = prefix+file
wget.download(filename)
print("Downloaded", i, "files out of", total)
i += 1
# In case the webpage doesn't like many rapid downloads
time.sleep(delay)
def download_files(tag):
paths_in_website = searchfiles(tags_url, host, tag, search)
[wget.download(path_in_website, out = tag) for path_in_website in paths_in_website]
def download_files():
paths_in_website = searchfiles()
[wget.download(path_in_website, out = "archive") for path_in_website in paths_in_website]