mirror of
https://github.com/Pakobbix/StartUI-oobabooga-webui
synced 2025-11-09 15:39:39 +00:00
Fixed Linux Terminal output.
This commit is contained in:
parent
b878c717a3
commit
8922d59b95
30
StartUI.py
30
StartUI.py
@ -33,12 +33,32 @@ def run_cmd_with_conda(cmd, env=None):
|
|||||||
# Open a separate terminal window and execute the command
|
# Open a separate terminal window and execute the command
|
||||||
subprocess.Popen(['start', 'cmd', '/k', full_cmd], shell=True, env=env)
|
subprocess.Popen(['start', 'cmd', '/k', full_cmd], shell=True, env=env)
|
||||||
elif platform.system() == 'Linux':
|
elif platform.system() == 'Linux':
|
||||||
# For Linux, activate the Conda environment using the conda command
|
# Define the necessary variables from the bash script
|
||||||
activate_cmd = f"conda activate {conda_env_path} && "
|
install_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
full_cmd = f"source ./installer_files/conda/etc/profile.d/conda.sh && conda run -p {conda_env_path} {cmd}"
|
conda_root_prefix = os.path.join(install_dir, "installer_files", "conda")
|
||||||
|
install_env_dir = os.path.join(install_dir, "installer_files", "env")
|
||||||
|
|
||||||
# Open a separate terminal window and execute the command
|
# For Linux, activate the Conda environment
|
||||||
process = subprocess.Popen(['gnome-terminal', '--', 'bash', '-c', full_cmd], env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
activate_cmd = f"source {os.path.join(conda_root_prefix, 'etc', 'profile.d', 'conda.sh')} && conda activate {install_env_dir}"
|
||||||
|
|
||||||
|
# Check for available terminal emulators
|
||||||
|
terminal_emulators = ['xdg-terminal', 'gnome-terminal', 'konsole', 'xfce4-terminal', 'mate-terminal', 'lxterminal', 'termite', 'tilix', 'xterm']
|
||||||
|
terminal_cmd = None
|
||||||
|
|
||||||
|
for emulator in terminal_emulators:
|
||||||
|
try:
|
||||||
|
subprocess.run([emulator, '--version'], check=True)
|
||||||
|
terminal_cmd = emulator
|
||||||
|
break
|
||||||
|
except FileNotFoundError:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if terminal_cmd is None:
|
||||||
|
raise RuntimeError("No compatible terminal emulator found.")
|
||||||
|
|
||||||
|
# Execute the command within the Conda environment in a separate terminal
|
||||||
|
print(cmd)
|
||||||
|
subprocess.Popen([terminal_cmd, '--', 'bash', '-c', f"{activate_cmd} && {cmd}"], env=env)
|
||||||
|
|
||||||
class MainWindow(QMainWindow):
|
class MainWindow(QMainWindow):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user