Skip to content

Commit

Permalink
modify gui.sh to validate requirements and apply args
Browse files Browse the repository at this point in the history
  • Loading branch information
zrma committed Mar 19, 2023
1 parent 00f74d2 commit 6bfdbaf
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
12 changes: 11 additions & 1 deletion gui.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
#!/bin/bash

# Activate the virtual environment
source venv/bin/activate
python kohya_gui.py

# Validate the requirements and store the exit code
python tools/validate_requirements.py
exit_code=$?

# If the exit code is 0, run the kohya_gui.py script with the command-line arguments
if [ $exit_code -eq 0 ]; then
python kohya_gui.py "$@"
fi
4 changes: 3 additions & 1 deletion tools/validate_requirements.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import sys
import pkg_resources

Expand Down Expand Up @@ -32,7 +33,8 @@
print("Error: The following packages have the wrong version:")
for requirement, expected_version, actual_version in wrong_version_requirements:
print(f" - {requirement} (expected version {expected_version}, found version {actual_version})")
print('\nRun \033[33mupgrade.ps1\033[0m or \033[33mpip install -U -r requirements.txt\033[0m to resolve the missing requirements listed above...')
upgrade_script = "upgrade.ps1" if os.name == "nt" else "upgrade.sh"
print(f"\nRun \033[33m{upgrade_script}\033[0m or \033[33mpip install -U -r requirements.txt\033[0m to resolve the missing requirements listed above...")

sys.exit(1)

Expand Down
16 changes: 16 additions & 0 deletions upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Check if there are any changes that need to be committed
if [[ -n $(git status --short) ]]; then
echo "There are changes that need to be committed. Please stash or undo your changes before running this script." >&2
exit 1
fi

# Pull the latest changes from the remote repository
git pull

# Activate the virtual environment
source venv/bin/activate

# Upgrade the required packages
pip install --upgrade -r requirements.txt

0 comments on commit 6bfdbaf

Please sign in to comment.