folder doesnt exist then then create it , but if I execute my script (second time) obviously will be already so I need to remove the folder , and download the file inside , but my current script overwrites the location, how can I do this?
import os, shutil, wget
base_path = os.path.dirname(os.path.abspath(__file__))
directory = os.path.join(base_path, 'demo')
# check for extraction directories existence
if not os.path.isdir(directory):
os.makedirs(directory)
else:
if os.path.exists(directory) and os.path.isdir(directory):
shutil.rmtree(directory)
#os.makedirs(directory)
remote_location = 'https://github.com/facebookresearch/SING/blob/master/sing/nsynth/examples.json.gz?raw=true'
try:
wget.download(remote_location, out=directory)
except:
pass
could you please describe more clearly? If the folder not exists, then make the folder and download the file inside it. If the folder exists, then what should your script do?
Обсуждают сегодня