Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check if the pkg exists and path is writable #1608

Merged
merged 1 commit into from
Nov 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions jsk_data/src/jsk_data/download_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ def download_data(pkg_name, path, url, md5, download_client=None,
compressed_bags = []
if not osp.isabs(path):
pkg_path = _get_package_source_path(pkg_name)
if not pkg_path:
print('Package [%s] is not found in current workspace. Skipping download' % pkg_name,
file=sys.stderr)
return True
path = osp.join(pkg_path, path)
if not osp.exists(osp.dirname(path)):
try:
Expand Down Expand Up @@ -175,11 +179,11 @@ def download_data(pkg_name, path, url, md5, download_client=None,
os.remove(cache_file)
try_download_count += 1
download(download_client, url, cache_file, quiet=quiet, chmod=chmod)
if osp.islink(path):
if osp.islink(path) and os.access(os.path.dirname(path), os.W_OK):
# overwrite the link
os.remove(path)
os.symlink(cache_file, path)
elif not osp.exists(path):
elif not osp.exists(path) and os.access(os.path.dirname(path), os.W_OK):
os.symlink(cache_file, path) # create link
else:
# not link and exists so skipping
Expand Down