check if invokeai is running before trying to update

- on windows systems, updating the .venv while invokeai is using it leads to
  corruption.
This commit is contained in:
Lincoln Stein
2023-04-09 16:57:14 -04:00
parent 2af511c98a
commit 31333a736c

View File

@@ -4,14 +4,13 @@ pip install <path_to_git_source>.
'''
import os
import platform
import psutil
import requests
from rich import box, print
from rich.console import Console, Group, group
from rich.console import Console, 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 ldm.invoke import __version__
@@ -32,6 +31,16 @@ else:
def get_versions()->dict:
return requests.get(url=INVOKE_AI_REL).json()
def invokeai_is_running()->bool:
for p in psutil.process_iter():
cmdline = p.cmdline()
matches = [x for x in cmdline if x.endswith('invokeai')]
if matches:
print(f':exclamation: [bold red]An InvokeAI instance appears to be running as process {p.pid}[/red bold]')
return True
return False
def welcome(versions: dict):
@group()
@@ -62,6 +71,10 @@ def welcome(versions: dict):
def main():
versions = get_versions()
if invokeai_is_running():
print(f':exclamation: [bold red]Please terminate all running instances of InvokeAI before updating.[/red bold]')
return
welcome(versions)
tag = None