Skip to content

Commit

Permalink
Added checking for local file copies to RAP download script.
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianStucky-USDA committed Oct 23, 2023
1 parent 2664e20 commit 580991c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions bin/download_rap.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from concurrent.futures import ThreadPoolExecutor
import subprocess as sp
import sys
from urllib.parse import urlparse
import os.path


vegcover_baseurl = 'http://rangeland.ntsg.umt.edu/data/rap/rap-vegetation-cover/v3/vegetation-cover-v3-{0}.tif'
Expand All @@ -16,9 +18,15 @@
# Download up to 10 files concurrently.
max_threads = 10


def download_file(url):
print(f'Downloading {url}...')
sp.run(['wget', '-q', url])
fname = os.path.basename(urlparse(url).path)
if os.path.isfile(fname):
print(f'{fname} already downloaded, skipping...')
else:
print(f'Downloading {url}...')
sp.run(['wget', '-q', url])


with ThreadPoolExecutor(max_workers=max_threads) as runner:
for year in vegcover_years:
Expand Down

0 comments on commit 580991c

Please sign in to comment.