Add support for custom user gui startup files
This commit is contained in:
parent
c47cb10384
commit
acf7d4785f
2
.gitignore
vendored
2
.gitignore
vendored
@ -8,3 +8,5 @@ build
|
||||
wd14_tagger_model
|
||||
.DS_Store
|
||||
locon
|
||||
gui-user.bat
|
||||
gui-user.ps1
|
||||
|
11
gui.ps1
11
gui.ps1
@ -4,7 +4,14 @@
|
||||
# Validate the requirements and store the exit code
|
||||
python.exe .\tools\validate_requirements.py
|
||||
|
||||
# If the exit code is 0, run the kohya_gui.py script with the command-line arguments
|
||||
# If the exit code is 0, read arguments from gui_parameters.txt (if it exists)
|
||||
# and run the kohya_gui.py script with the command-line arguments
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
python.exe kohya_gui.py $args
|
||||
$argsFromFile = @()
|
||||
if (Test-Path .\gui_parameters.txt) {
|
||||
$argsFromFile = Get-Content .\gui_parameters.txt -Encoding UTF8 | Where-Object { $_ -notmatch "^#" } | Foreach-Object { $_ -split " " }
|
||||
}
|
||||
$args_combo = $argsFromFile + $args
|
||||
Write-Host "The arguments passed to this script were: $args_combo"
|
||||
python.exe kohya_gui.py $args_combo
|
||||
}
|
9
setup.py
9
setup.py
@ -1,3 +1,10 @@
|
||||
from setuptools import setup, find_packages
|
||||
import subprocess
|
||||
import os
|
||||
import sys
|
||||
|
||||
setup(name = "library", version="1.0.2", packages = find_packages())
|
||||
# Call the create_user_files.py script
|
||||
script_path = os.path.join("tools", "create_user_files.py")
|
||||
subprocess.run([sys.executable, script_path])
|
||||
|
||||
setup(name="library", version="1.0.3", packages=find_packages())
|
||||
|
37
tools/create_user_files.py
Normal file
37
tools/create_user_files.py
Normal file
@ -0,0 +1,37 @@
|
||||
import os
|
||||
|
||||
bat_content = r'''@echo off
|
||||
REM Example of how to start the GUI with custom arguments. In this case how to auto launch the browser:
|
||||
REM call gui.bat --inbrowser
|
||||
REM
|
||||
REM You can add many arguments on the same line
|
||||
REM
|
||||
call gui.bat --inbrowser
|
||||
'''
|
||||
|
||||
ps1_content = r'''# Example of how to start the GUI with custom arguments. In this case how to auto launch the browser:
|
||||
# .\gui.ps1 --inbrowser
|
||||
#
|
||||
# You can add many arguments on the same line
|
||||
#
|
||||
# & .\gui.ps1 --inbrowser --server_port 2345
|
||||
|
||||
& .\gui.ps1 --inbrowser
|
||||
'''
|
||||
|
||||
bat_filename = 'gui-user.bat'
|
||||
ps1_filename = 'gui-user.ps1'
|
||||
|
||||
if not os.path.exists(bat_filename):
|
||||
with open(bat_filename, 'w') as bat_file:
|
||||
bat_file.write(bat_content)
|
||||
print(f"File created: {bat_filename}")
|
||||
else:
|
||||
print(f"File already exists: {bat_filename}")
|
||||
|
||||
if not os.path.exists(ps1_filename):
|
||||
with open(ps1_filename, 'w') as ps1_file:
|
||||
ps1_file.write(ps1_content)
|
||||
print(f"File created: {ps1_filename}")
|
||||
else:
|
||||
print(f"File already exists: {ps1_filename}")
|
Loading…
Reference in New Issue
Block a user