Skip to content
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
33 changes: 33 additions & 0 deletions shapepipe/utilities/canfar.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

"""

import os
import sys

try:
import vos.commands as vosc
except ImportError: # pragma: no cover
Expand Down Expand Up @@ -88,3 +91,33 @@ def __call__(self, *args, **kwargs):
except:
raise vosError('Error in VOs command: {}'
''.format(self._command.__name__))

def download(source, target, verbose=False):
"""Download file from vos.

Parameters
----------
source : string
source path on vos
target : string
target path
verbose : bool, optional, default=False
verbose output if True

Returns
-------
status : bool
status, True/False or success/failure
"""

if not os.path.exists(target):
sys.argv = ['vcp', source, target]
if verbose:
print('Downloading file {} to {}...'.format(source, target))
vcp = vosHandler('vcp')
vcp()
if verbose:
print('Download finished.')
else:
if verbose:
print('Target file {} exists, skipping download.'.format(target))