def _listdir(working_dir, base='/'): # type: (Storage, str) -> dict """ We took this code from pyunicore Storage.listdir method and extended it to use a subdirectory. Looking at the method signature, it should have had this behavior, but the 'base' argument is not used later inside the method code. Probably will be fixed soon in their API, so we could delete this. :return: dict of {str: PathFile} objects """ ret = {} try: for path, meta in working_dir.contents(base)['content'].items(): path_url = working_dir.path_urls['files'] + path path = path[1:] # strip leading '/' if meta['isDirectory']: ret[path] = unicore_client.PathDir(working_dir, path_url, path) else: ret[path] = unicore_client.PathFile( working_dir, path_url, path) return ret except HTTPError as http_error: if http_error.response.status_code == 404: raise OperationException( "Folder {} is not present on HPC storage.".format(base)) raise http_error
def _listdir(working_dir, base='/'): # type: (Storage, str) -> dict """ We took this code from pyunicore Storage.listdir method and extended it to use a subdirectory. Looking at the method signature, it should have had this behavior, but the 'base' argument is not used later inside the method code. Probably will be fixed soon in their API, so we could delete this. :return: dict of {str: PathFile} objects """ ret = {} for path, meta in working_dir.contents(base)['content'].items(): path_url = working_dir.path_urls['files'] + path path = path[1:] # strip leading '/' if meta['isDirectory']: ret[path] = unicore_client.PathDir(working_dir, path_url, path) else: ret[path] = unicore_client.PathFile(working_dir, path_url, path) return ret