mergin/cli.py
def pull(ctx):
    """Fetch changes from Mergin repository."""
    mc = ctx.obj["client"]
    if mc is None:
        return
    directory = os.getcwd()
    try:
        job = pull_project_async(mc, directory)
        if job is None:
            click.echo("Project is up to date")
            return
        with click.progressbar(length=job.total_size) as bar:
            last_transferred_size = 0
            while pull_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
        pull_project_finalize(job)
        click.echo("Done")
    except InvalidProject as e:
        click.secho("Invalid project directory ({})".format(str(e)), fg="red")
    except ClientError as e:
        click.secho("Error: " + str(e), fg="red")
        return
    except KeyboardInterrupt:
        click.secho("Cancelling...")
        pull_project_cancel(job)
    except Exception as e:
        _print_unhandled_exception()
Fetch changes from Mergin repository.
Fetch changes from Mergin repository.
Fetch changes from Mergin repository .
def pull(ctx):
    mc = ctx.obj["client"]
    if mc is None:
        return
    directory = os.getcwd()
    try:
        job = pull_project_async(mc, directory)
        if job is None:
            click.echo("Project is up to date")
            return
        with click.progressbar(length=job.total_size) as bar:
            last_transferred_size = 0
            while pull_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
        pull_project_finalize(job)
        click.echo("Done")
    except InvalidProject as e:
        click.secho("Invalid project directory ({})".format(str(e)), fg="red")
    except ClientError as e:
        click.secho("Error: " + str(e), fg="red")
        return
    except KeyboardInterrupt:
        click.secho("Cancelling...")
        pull_project_cancel(job)
    except Exception as e:
        _print_unhandled_exception()
def pull ( ctx ) : mc = ctx . obj [ "client" ] if mc is None : return directory = os . getcwd ( ) try : job = pull_project_async ( mc , directory ) if job is None : click . echo ( "Project is up to date" ) return with click . progressbar ( length = job . total_size ) as bar : last_transferred_size = 0 while pull_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 pull_project_finalize ( job ) click . echo ( "Done" ) except InvalidProject as e : click . secho ( "Invalid project directory ({})" . format ( str ( e ) ) , fg = "red" ) except ClientError as e : click . secho ( "Error: " + str ( e ) , fg = "red" ) return except KeyboardInterrupt : click . secho ( "Cancelling..." ) pull_project_cancel ( job ) except Exception as e : _print_unhandled_exception ( )
Fetch changes from Mergin repository.
Fetch changes from Mergin repository .
"""Fetch changes from Mergin repository.""" # 100ms # the update() needs increment only
ctx