Browse Source

added --gui option to fabric. this will open the gui

pull/325/head
Jonathan Dunn 8 months ago
parent
commit
fda9e9866d
  1. 6
      installer/client/cli/fabric.py
  2. 35
      installer/client/cli/utils.py

6
installer/client/cli/fabric.py

@ -1,4 +1,4 @@
from .utils import Standalone, Update, Setup, Alias
from .utils import Standalone, Update, Setup, Alias, run_electron_app
import argparse
import sys
import os
@ -28,6 +28,7 @@ def main():
const="analyzepaper.txt",
default=None,
)
parser.add_argument("--gui", help="Use the GUI", action="store_true")
parser.add_argument(
"--stream",
"-s",
@ -90,6 +91,9 @@ def main():
from .utils import AgentSetup
AgentSetup().run()
sys.exit()
if args.gui:
run_electron_app()
sys.exit()
if args.update:
Update()
Alias()

35
installer/client/cli/utils.py

@ -8,6 +8,7 @@ import platform
from dotenv import load_dotenv
import zipfile
import tempfile
import subprocess
import re
import shutil
@ -659,3 +660,37 @@ class AgentSetup:
else:
# If it does not end with a newline, add one before the new entries
f.write(f"\n{browserless_entry}\n{serper_entry}\n")
def run_electron_app():
# Step 1: Set CWD to the directory of the script
os.chdir(os.path.dirname(os.path.realpath(__file__)))
# Step 2: Check for the './installer/client/gui' directory
target_dir = '../gui'
if not os.path.exists(target_dir):
print(f"The directory {
target_dir} does not exist. Please check the path and try again.")
return
# Step 3: Check for NPM installation
try:
subprocess.run(['npm', '--version'], check=True,
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
except subprocess.CalledProcessError:
print("NPM is not installed. Please install NPM and try again.")
return
# If this point is reached, NPM is installed.
# Step 4: Change directory to the Electron app's directory
os.chdir(target_dir)
# Step 5: Run 'npm install' and 'npm start'
try:
print("Running 'npm install'... This might take a few minutes.")
subprocess.run(['npm', 'install'], check=True)
print(
"'npm install' completed successfully. Starting the Electron app with 'npm start'...")
subprocess.run(['npm', 'start'], check=True)
except subprocess.CalledProcessError as e:
print(f"An error occurred while executing NPM commands: {e}")

Loading…
Cancel
Save