def exec(bossman: Bossman, glob, *args, **kwargs): resources = bossman.get_resources(glob=glob) revisions = bossman.get_revisions(resources=resources) for revision in revisions: view = RevisionView(bossman, revision, resources) console.print(view, end="") console.print("\n")
def exec(bossman: Bossman, glob, *args, **kwargs): bossman.repo.fetch_notes("*") resources = bossman.get_resources(*glob) revisions = bossman.get_revisions(resources=resources) for revision in revisions: view = RevisionView(bossman, revision, resources) console.print(view, end="") console.print("\n")
def exec(bossman: Bossman, glob, force=False, **kwargs): resources = bossman.get_resources(glob=glob) for resource in resources: console.rule(str(resource)) status = bossman.get_resource_status(resource) missing_revisions = list(status.missing_revisions) console.print(":notebook: {} changes pending".format(len(missing_revisions)), justify="center") if status.dirty: if not force: console.print(":stop_sign: [magenta]dirty, skipping[/magenta] :stop_sign:", justify="center") continue else: console.print(":exclamation_mark: [red]dirty, force applying[/red] :exclamation_mark:", justify="center") for (idx, revision) in enumerate(missing_revisions): console.print(Panel(revision, title="{}/{}".format(idx+1, len(missing_revisions)))) bossman.apply_change(resource, revision) else: console.print(":cookie: [green]all done[green] :cookie:", justify="center")
def exec(bossman: Bossman, glob, *args, **kwargs): resources = bossman.get_resources(glob=glob) if len(resources): table = Table() table.add_column("Resource") table.add_column("Revision") table.add_column("Pending") table.add_column("Clean") for resource in resources: status = bossman.get_resource_status(resource) table.add_row(resource, "".join(render_revision(resource, status)), "".join(render_pending(resource, status)), "".join(render_clean(resource, status))) print(table) else: print( "No resources to show: check the glob pattern if provided, or the configuration." )
def exec(bossman: Bossman, glob, *args, **kwargs): resources = bossman.get_resources(*glob) if len(resources): print("On branch", bossman.get_current_branch()) statuses = bossman.get_resource_statuses(resources) col_width = min( max(len(resource.path) for resource in resources) + 2, 60) table = Table(expand=False, box=box.HORIZONTALS, show_lines=True) table.add_column("Resource", width=col_width) table.add_column("Status") for resource, status in zip(resources, statuses): table.add_row(resource, status) print(table) else: print( "No resources to show: check the glob pattern if provided, or the configuration." )
def exec(bossman: Bossman, glob, *args, **kwargs): resources = bossman.get_resources(glob=glob) if len(resources): table = Table() table.add_column("Resource") table.add_column("Validation") for resource in resources: try: bossman.validate(resource) status = ":thumbs_up:" except: status = ":thumbs_down:" table.add_row( resource, status, ) print(table) else: print( "No resources to show: check the glob pattern if provided, or the configuration." )
def exec(bossman: Bossman, yes, rev, glob, action, *args, **kwargs): resources = bossman.get_resources(*glob) revision = bossman.get_revision(rev, resources) console.print("Preparing to {}:".format(action)) console.print(Panel(revision)) console.print(Columns(resources, expand=False, equal=True)) if not yes and not console.is_terminal: console.print( "Input or output is not a terminal. Consider using --yes to forgo validation." ) return if (not yes): if Prompt.ask("Shall we proceed?", choices=("yes", "no"), default="no") != "yes": console.print("OK!") return with Progress( "[progress.description]{task.description}", BarColumn(bar_width=20), TextColumn( "[progress.description]{task.fields[activation_status]}"), ) as progress_ui: from collections import defaultdict last_status = defaultdict(lambda: None) def on_update(task_id, resource: ResourceABC, status: str, progress: float): if isinstance(progress, (float, int)): progress_ui.start_task(task_id) progress = progress * 100 progress_ui.update(task_id, completed=progress, activation_status=status) progress_ui.refresh() if not console.is_terminal: res_last_status = last_status.get(resource.path) if res_last_status != status: console.print(resource, status) last_status[resource.path] = status futures = [] with ThreadPoolExecutor(100, "prereleasse") as executor: for resource in resources: description = str(resource) if hasattr(resource, "__rich__"): description = resource.__rich__() task_id = progress_ui.add_task(description, total=100, activation_status="-", start=False) _on_update = partial(on_update, task_id) futures.append( executor.submit(getattr(bossman, action), resource, revision, _on_update)) for resource, future in zip(resources, futures): try: future.result() except Exception as e: print(":exclamation_mark:", resource, e) console.print_exception()