def genomespace_list_files(args): client = get_client(args) folder_contents = client.list(args.folder_url) for folder in folder_contents.contents: print("{isdir:<3s} {owner:<10s} {size:>10s} {last_modified:>26s}" " {name:s}".format(isdir="d" if folder.is_directory else "_", owner=folder.owner["name"] or "", size=util.format_file_size(folder.size), last_modified=folder.last_modified or "", name=folder.name))
def genomespace_list_files(args): client = get_client(args) folder_contents = client.list(args.folder_url) for folder in folder_contents["contents"]: print("{isdir:<3s} {owner:<10s} {size:>10s} {last_modified:>26s}" " {name:s}".format( isdir="d" if folder["isDirectory"] else "_", owner=folder["owner"]["name"], size=util.format_file_size(folder["size"]), last_modified=folder.get("lastModified", ""), name=folder.get("name")))
def download(self, download_info, destination): if not destination or os.path.isdir(destination): disassembled_uri = urlparse(download_info['Location']) filename = os.path.basename(disassembled_uri.path) destination = os.path.join(destination, filename) with open(destination, 'wb') as handle: response = requests.get(download_info['Location'], stream=True) response.raise_for_status() total_length = response.headers.get('content-length') bytes_copied = 0 for block in response.iter_content(65536): handle.write(block) bytes_copied += len(block) if log.isEnabledFor(logging.INFO): print("Progress: {progress:>8s} of {total:>8s}" " copied".format( progress=util.format_file_size(bytes_copied), total=util.format_file_size(int(total_length)) if total_length else "unknown size", end='\r')) if log.isEnabledFor(logging.INFO): print("\n")
def download(self, download_info, destination): if not destination or os.path.isdir(destination): disassembled_uri = urlparse(download_info['Location']) filename = os.path.basename(disassembled_uri.path) destination = os.path.join(destination, filename) with open(destination, 'wb') as handle: response = requests.get(download_info['Location'], stream=True) response.raise_for_status() total_length = response.headers.get('content-length') bytes_copied = 0 for block in response.iter_content(65536): handle.write(block) bytes_copied += len(block) if log.isEnabledFor(logging.INFO): print("Progress: {progress:>8s} of {total:>8s}" " copied".format( progress=util.format_file_size(bytes_copied), total=util.format_file_size(int(total_length)) if total_length else "unknown size"), end='\r') if log.isEnabledFor(logging.INFO): print("\n")