Skip to content

Commit

Permalink
allow separate imagedownloading with parameter (legacy)
Browse files Browse the repository at this point in the history
  • Loading branch information
johagge authored and timonegk committed Jan 1, 2021
1 parent 069c166 commit 4b86609
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions imagetagger/imagetagger/images/templates/images/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,25 @@
sys.exit()

BaseUrl = "{{ base_url }}" + "/"
separate_download = False
if "--separate" in sys.argv or "-s" in sys.argv:
separate_download = True
# remove parameters from list
if "--separate" in sys.argv:
sys.argv.remove("--separate")
if "-s" in sys.argv:
sys.argv.remove("-s")
print("The images will be downloaded separately instead of as zip.")
if len(sys.argv) < 2:
imageset = input("Imagesets you want to download, separated by a ',' or ' ':")
else:
if sys.argv[1] == '-h':
print("This script will download images from the specified imageset for you.")
print("The images will be downloaded from: {}".format(BaseUrl))
print("If errors occur during the download you will be notified at the end of the script execution")
print("Just execute it with ./imagetagger_dl_script.py")
print("If you want to download the images separately instead of as a zip (this was done in the past),")
print("call the script with ./imagetagger_dl_script.py --separate imgsetID1, imgsetID2")
print("Otherwise just execute it with ./imagetagger_dl_script.py")
sys.exit()
else:
imageset = " ".join(sys.argv[1:])
Expand Down Expand Up @@ -67,6 +78,7 @@


def download_zip(current_imageset):
print(f"Now downloading {current_imageset}")
if not os.path.exists(os.path.join(os.getcwd(), filename, current_imageset)):
os.makedirs(os.path.join(os.getcwd(), filename, current_imageset))
ziplink = f"{BaseUrl}images/imageset/{current_imageset}/download/"
Expand Down Expand Up @@ -132,7 +144,10 @@ def download_imageset(current_imageset):

for imgset in imagesets:
if imgset is not " ":
download_zip(imgset)
if not separate_download:
download_zip(imgset)
else:
download_imageset(imgset)
if errorlist:
print("There have been errors while downloading the following imagesets: ")
for item in errorlist:
Expand Down

0 comments on commit 4b86609

Please sign in to comment.