From 8eaf1c40339f192d8d0002d0652e946141b6a123 Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Thu, 23 Feb 2023 16:33:57 -0500 Subject: [PATCH] Revert "(updater) style 'pip' progress to use dark background" This reverts commit 89239d1c54b67dda883773fc65ba08615db8aa27. - This was making a subprocess call to 'bash', and hence crashing on windows systems! --- ldm/invoke/config/invokeai_update.py | 54 +++++++++++----------------- 1 file changed, 20 insertions(+), 34 deletions(-) diff --git a/ldm/invoke/config/invokeai_update.py b/ldm/invoke/config/invokeai_update.py index 6e3bd6fbe1..8ad7290136 100644 --- a/ldm/invoke/config/invokeai_update.py +++ b/ldm/invoke/config/invokeai_update.py @@ -2,18 +2,16 @@ Minimalist updater script. Prompts user for the tag or branch to update to and runs pip install . ''' - +import os import platform import requests -import subprocess from rich import box, print -from rich.console import Console, group +from rich.console import Console, Group, group from rich.panel import Panel from rich.prompt import Prompt from rich.style import Style +from rich.syntax import Syntax from rich.text import Text -from rich.live import Live -from rich.table import Table from ldm.invoke import __version__ @@ -23,19 +21,17 @@ INVOKE_AI_REL="https://api.github.com/repos/invoke-ai/InvokeAI/releases" OS = platform.uname().system ARCH = platform.uname().machine -ORANGE_ON_DARK_GREY = Style(bgcolor="grey23", color="orange1") - if OS == "Windows": # Windows terminals look better without a background colour console = Console(style=Style(color="grey74")) else: - console = Console(style=Style(color="grey74", bgcolor="grey23")) + console = Console(style=Style(color="grey74", bgcolor="grey19")) def get_versions()->dict: return requests.get(url=INVOKE_AI_REL).json() def welcome(versions: dict): - + @group() def text(): yield f'InvokeAI Version: [bold yellow]{__version__}' @@ -48,55 +44,45 @@ def welcome(versions: dict): [3] Manually enter the tag or branch name you wish to update''' console.rule() - console.print( + print( Panel( title="[bold wheat1]InvokeAI Updater", renderable=text(), box=box.DOUBLE, expand=True, padding=(1, 2), - style=ORANGE_ON_DARK_GREY, + style=Style(bgcolor="grey23", color="orange1"), subtitle=f"[bold grey39]{OS}-{ARCH}", ) ) - # console.rule is used instead of console.line to maintain dark background - # on terminals where light background is the default - console.rule(characters=" ") + console.line() def main(): versions = get_versions() welcome(versions) tag = None - choice = Prompt.ask(Text.from_markup(('[grey74 on grey23]Choice:')),choices=['1','2','3'],default='1') - + choice = Prompt.ask('Choice:',choices=['1','2','3'],default='1') + if choice=='1': tag = versions[0]['tag_name'] elif choice=='2': tag = 'main' elif choice=='3': - tag = Prompt.ask('[grey74 on grey23]Enter an InvokeAI tag or branch name') - - console.print(Panel(f':crossed_fingers: Upgrading to [yellow]{tag}[/yellow]', box=box.MINIMAL, style=ORANGE_ON_DARK_GREY)) + tag = Prompt.ask('Enter an InvokeAI tag or branch name') + print(f':crossed_fingers: Upgrading to [yellow]{tag}[/yellow]') cmd = f'pip install {INVOKE_AI_SRC}/{tag}.zip --use-pep517' - - progress = Table.grid(expand=True) - progress_panel = Panel(progress, box=box.MINIMAL, style=ORANGE_ON_DARK_GREY) - - with subprocess.Popen(['bash', '-c', cmd], stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc: - progress.add_column() - with Live(progress_panel, console=console, vertical_overflow='visible'): - while proc.poll() is None: - for l in iter(proc.stdout.readline, b''): - progress.add_row(l.decode().strip(), style=ORANGE_ON_DARK_GREY) - if proc.returncode == 0: - console.rule(f':heavy_check_mark: Upgrade successful') - else: - console.rule(f':exclamation: [bold red]Upgrade failed[/red bold]') - + print('') + print('') + if os.system(cmd)==0: + print(f':heavy_check_mark: Upgrade successful') + else: + print(f':exclamation: [bold red]Upgrade failed[/red bold]') + if __name__ == "__main__": try: main() except KeyboardInterrupt: pass +