def download_classifications(
workflow_id,
output_file,
generate,
generate_timeout
):
"""
Downloads a workflow-specific classifications export for the given workflow.
OUTPUT_FILE will be overwritten if it already exists. Set OUTPUT_FILE to -
to output to stdout.
"""
workflow = Workflow.find(workflow_id)
if generate:
click.echo("Generating new export...", err=True)
export = workflow.get_export(
'classifications',
generate=generate,
wait_timeout=generate_timeout
)
with click.progressbar(
export.iter_content(chunk_size=1024),
label='Downloading',
length=(int(export.headers.get('content-length')) / 1024 + 1),
file=click.get_text_stream('stderr'),
) as chunks:
for chunk in chunks:
output_file.write(chunk)
评论列表
文章目录