Skip to content

Commit

Permalink
Merge pull request #1771 from nakane11/wget-timeout
Browse files Browse the repository at this point in the history
[jsk_data/download_data.py] Add timeout argument to download() for wget
  • Loading branch information
k-okada committed Dec 8, 2022
2 parents a8651dc + 375c5c5 commit f680d3f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions jsk_data/src/jsk_data/download_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,26 @@ def decompress_rosbag(path, quiet=False, chmod=True):
print('[%s] Finished decompressing the rosbag' % path)


def download(client, url, output, quiet=False, chmod=True):
def download(client, url, output, quiet=False, chmod=True, timeout=30):
print('[%s] Downloading from %s' % (output, url))
cmd = '{client} {url} -O {output}'.format(client=client, url=url,
output=output)
if client == 'wget':
cmd = '{client} {url} -O {output} -T {timeout} --tries 1'.format(client=client, url=url,
output=output, timeout=timeout)
else:
cmd = '{client} {url} -O {output}'.format(client=client, url=url,
output=output)
if quiet:
cmd += ' --quiet'
try:
subprocess.call(shlex.split(cmd))
status = subprocess.call(shlex.split(cmd))
finally:
if chmod:
if not is_file_writable(output):
os.chmod(output, 0o766)
print('[%s] Finished downloading' % output)
if status == 0:
print('[%s] Finished downloading' % output)
else:
print('[%s] Failed downloading. exit_status: %d' % (output, status))


def check_md5sum(path, md5):
Expand Down

0 comments on commit f680d3f

Please sign in to comment.