mergin/cli.py
def download_file(ctx, filepath, output, version):
    """
    Download project file at specified version. `project` needs to be a combination of namespace/project.
    If no version is given, the latest will be fetched.
    """
    mc = ctx.obj["client"]
    if mc is None:
        return
    mp = MerginProject(os.getcwd())
    project_path = mp.metadata["name"]
    try:
        job = download_file_async(mc, project_path, filepath, output, version)
        with click.progressbar(length=job.total_size) as bar:
            last_transferred_size = 0
            while download_project_is_running(job):
                time.sleep(1 / 10)  # 100ms
                new_transferred_size = job.transferred_size
                bar.update(new_transferred_size - last_transferred_size)  # the update() needs increment only
                last_transferred_size = new_transferred_size
        download_file_finalize(job)
        click.echo("Done")
    except KeyboardInterrupt:
        click.secho("Cancelling...")
        download_project_cancel(job)
    except ClientError as e:
        click.secho("Error: " + str(e), fg="red")
    except Exception as e:
        _print_unhandled_exception()

    Download project file at specified version. `project` needs to be a combination of namespace/project.
    If no version is given, the latest will be fetched.
    
Download project file at specified version. `project` needs to be a combination of namespace/project.
If no version is given, the latest will be fetched.
Download project file at specified version . ` project ` needs to be a combination of namespace / project . If no version is given the latest will be fetched .
def download_file(ctx, filepath, output, version):
    mc = ctx.obj["client"]
    if mc is None:
        return
    mp = MerginProject(os.getcwd())
    project_path = mp.metadata["name"]
    try:
        job = download_file_async(mc, project_path, filepath, output, version)
        with click.progressbar(length=job.total_size) as bar:
            last_transferred_size = 0
            while download_project_is_running(job):
                time.sleep(1 / 10)  
                new_transferred_size = job.transferred_size
                bar.update(new_transferred_size - last_transferred_size)  
                last_transferred_size = new_transferred_size
        download_file_finalize(job)
        click.echo("Done")
    except KeyboardInterrupt:
        click.secho("Cancelling...")
        download_project_cancel(job)
    except ClientError as e:
        click.secho("Error: " + str(e), fg="red")
    except Exception as e:
        _print_unhandled_exception()
def download_file ( ctx , filepath , output , version ) : mc = ctx . obj [ "client" ] if mc is None : return mp = MerginProject ( os . getcwd ( ) ) project_path = mp . metadata [ "name" ] try : job = download_file_async ( mc , project_path , filepath , output , version ) with click . progressbar ( length = job . total_size ) as bar : last_transferred_size = 0 while download_project_is_running ( job ) : time . sleep ( 1 / 10 ) new_transferred_size = job . transferred_size bar . update ( new_transferred_size - last_transferred_size ) last_transferred_size = new_transferred_size download_file_finalize ( job ) click . echo ( "Done" ) except KeyboardInterrupt : click . secho ( "Cancelling..." ) download_project_cancel ( job ) except ClientError as e : click . secho ( "Error: " + str ( e ) , fg = "red" ) except Exception as e : _print_unhandled_exception ( )
Download project file at specified version.
Download project file at specified version .
"""
    Download project file at specified version. `project` needs to be a combination of namespace/project.
    If no version is given, the latest will be fetched.
    """ # 100ms # the update() needs increment only
ctx
filepath
output
version