Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4 #348

Merged
merged 1 commit into from
Nov 2, 2024
Merged

4 #348

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions LaunchFile/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def _(text, lang="EN"):


def load_settings():
if not os.path.exists('Settings.json'):
if not os.path.exists('TechnicalFiles/Settings.json'):
default_settings = {
"language": "EN",
"share_mode": False,
Expand Down Expand Up @@ -422,11 +422,11 @@ def load_settings():
"font_mono": "Courier New"
}
}
with open('Settings.json', 'w') as f:
with open('TechnicalFiles/Settings.json', 'w') as f:
json.dump(default_settings, f, indent=4)
return default_settings

with open('Settings.json', 'r') as f:
with open('TechnicalFiles/Settings.json', 'r') as f:
settings = json.load(f)

if settings['share_server_address'] == "":
Expand All @@ -439,7 +439,7 @@ def save_settings(settings):
if settings['share_server_address'] is None:
settings['share_server_address'] = ""

with open('Settings.json', 'w') as f:
with open('TechnicalFiles/Settings.json', 'w') as f:
json.dump(settings, f, indent=4)


Expand Down Expand Up @@ -13439,6 +13439,7 @@ def create_footer():
create_footer()

project_root = os.getcwd()
project_image = "TechnicalFiles/project-image.png"

app.queue(api_open=settings['api_open'], max_size=settings['queue_max_size'], status_update_rate=settings['status_update_rate'])
app.launch(
Expand All @@ -13452,7 +13453,7 @@ def create_footer():
server_port=settings['server_port'],
max_file_size=settings['max_file_size'] * gr.FileSize.MB,
share_server_address=settings['share_server_address'] if settings['share_server_address'] else None,
favicon_path="project-image.png",
favicon_path=project_image,
allowed_paths=[project_root],
auth_message=_("Welcome to NeuroSandboxWebUI!", lang)
)
6 changes: 3 additions & 3 deletions Start.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ call "%CURRENT_DIR%venv\Scripts\activate.bat"
py "%CURRENT_DIR%TechnicalFiles\first_setup.py"

echo Attempting to read Settings.json...
if not exist Settings.json (
if not exist TechnicalFiles\Settings.json (
echo Settings.json file not found!
pause
exit /b
)

for /f "tokens=2 delims=:, " %%a in ('type Settings.json ^| findstr "hf_token"') do set HF_TOKEN=%%~a
for /f "tokens=2 delims=:, " %%a in ('type TechnicalFiles\Settings.json ^| findstr "hf_token"') do set HF_TOKEN=%%~a
echo HF_TOKEN value: "%HF_TOKEN%"
if "%HF_TOKEN%"=="" (
echo HF token is empty or not found in Settings.json. Please add your Hugging Face token to this file.
type Settings.json
type TechnicalFiles\Settings.json
pause
exit /b
)
Expand Down
6 changes: 3 additions & 3 deletions Start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ source "$CURRENT_DIR/venv/bin/activate"
python "$CURRENT_DIR/TechnicalFiles/first_setup.py"

echo "Attempting to read Settings.json..."
if [ ! -f Settings.json ]; then
if [ ! -f TechnicalFiles/Settings.json ]; then
echo "Settings.json file not found!"
exit 1
fi

echo "Contents of Settings.json:"
cat Settings.json
cat TechnicalFiles/Settings.json

HF_TOKEN=$(grep -oP '"hf_token"\s*:\s*"\K[^"]+' Settings.json)
HF_TOKEN=$(grep -oP '"hf_token"\s*:\s*"\K[^"]+' TechnicalFiles/Settings.json)

echo "HF_TOKEN value: '$HF_TOKEN'"

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions TechnicalFiles/first_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def load_settings() -> Dict:
try:
with open('Settings.json', 'r', encoding='utf-8') as f:
with open('TechnicalFiles/Settings.json', 'r', encoding='utf-8') as f:
return json.load(f)
except FileNotFoundError:
print("Ошибка: Файл Settings.json не найден!")
Expand All @@ -21,7 +21,7 @@ def load_settings() -> Dict:


def save_settings(settings: Dict) -> None:
with open('Settings.json', 'w', encoding='utf-8') as f:
with open('TechnicalFiles/Settings.json', 'w', encoding='utf-8') as f:
json.dump(settings, f, indent=4, ensure_ascii=False)


Expand Down
File renamed without changes
Loading