This commit is contained in:
D-Pyro 2024-01-13 14:24:23 +00:00 committed by GitHub
commit 629b43af65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 74 additions and 26 deletions

2
host/config.ini Normal file
View File

@ -0,0 +1,2 @@
[Directories]
Output = D:\Desktop\Gamecard

View File

@ -49,6 +49,8 @@ import usb.util
import warnings
import base64
import configparser
import tkinter as tk
import tkinter.ttk as ttk
from tkinter import filedialog, messagebox, font, scrolledtext
@ -136,9 +138,14 @@ COPYRIGHT_TEXT = f'Copyright (c) {COPYRIGHT_YEAR}, {USB_DEV_MANUFACTURER}'
SERVER_START_MSG = f'Please connect a Nintendo Switch console running {USB_DEV_PRODUCT}.'
SERVER_STOP_MSG = f'Exit {USB_DEV_PRODUCT} on your console or disconnect it at any time to stop the server.'
# Load the configuration from the INI file
config = configparser.ConfigParser()
config.read('config.ini')
# Default directory paths.
INITIAL_DIR = os.path.dirname(os.path.abspath(os.path.expanduser(os.path.expandvars(sys.argv[0]))))
DEFAULT_DIR = os.path.join(INITIAL_DIR, USB_DEV_PRODUCT)
# Get the default directory from the INI file or use a fallback if not present
DEFAULT_DIR = config.get('Directories', 'Output', fallback=os.path.join(INITIAL_DIR, USB_DEV_PRODUCT))
# Application icon (PNG).
# Embedded to load it as the icon for all windows using PhotoImage (which doesn't support ICO files) + wm_iconphoto.
@ -629,7 +636,7 @@ def usbGetDeviceEndpoints() -> bool:
if not g_cliMode:
utilsLogException(traceback.format_exc())
g_logger.error('Fatal error ocurred while enumerating USB devices.')
g_logger.error('Fatal error occurred while enumerating USB devices.')
if g_isWindows:
g_logger.error('Try reinstalling the libusbK driver using Zadig.')

View File

@ -1,24 +1,24 @@
@echo off
set scriptdir=%~dp0
set scriptdir=%scriptdir:~0,-1%
set venvname=standalone
set venvscripts=%scriptdir%\%venvname%\Scripts
set venvpython=%venvscripts%\python.exe
cd /D "%scriptdir%"
python -m venv "%venvname%"
"%venvpython%" -m pip install --upgrade nuitka -r requirements-win32.txt
"%venvpython%" -m nuitka --standalone --onefile --deployment --disable-console --windows-icon-from-ico=nxdt.ico --enable-plugin=tk-inter nxdt_host.py
rmdir /s /q nxdt_host.build
rmdir /s /q nxdt_host.dist
rmdir /s /q nxdt_host.onefile-build
rmdir /s /q standalone
pause
@echo off
set scriptdir=%~dp0
set scriptdir=%scriptdir:~0,-1%
set venvname=standalone
set venvscripts=%scriptdir%\%venvname%\Scripts
set venvpython=%venvscripts%\python.exe
cd /D "%scriptdir%"
python -m venv "%venvname%"
"%venvpython%" -m pip install --upgrade nuitka -r requirements-win32.txt
"%venvpython%" -m nuitka --standalone --onefile --deployment --disable-console --windows-icon-from-ico=nxdt.ico --enable-plugin=tk-inter nxdt_host.py
rmdir /s /q nxdt_host.build
rmdir /s /q nxdt_host.dist
rmdir /s /q nxdt_host.onefile-build
rmdir /s /q standalone
pause

View File

@ -0,0 +1,39 @@
@echo off
rem Get the directory of the script
set scriptdir=%~dp0
set scriptdir=%scriptdir:~0,-1%
rem Set up virtual environment variables
set venvname=standalone
set venvdir=%scriptdir%\%venvname%
rem Create a virtual environment
python -m venv "%venvdir%"
rem Activate the virtual environment
call "%venvdir%\Scripts\activate"
rem Install PyInstaller
pip install --upgrade pyinstaller
rem Install additional requirements
pip install -r requirements-win32.txt
rem Use PyInstaller to create a standalone executable
pyinstaller --onefile --noconsole --icon=nxdt.ico nxdt_host.py
rem Deactivate the virtual environment
call deactivate
rem Move the executable to the script directory
move "%scriptdir%\dist\nxdt_host.exe" "%scriptdir%"
timeout /t 1 /nobreak > nul
rem Clean up temporary files
rmdir /s /q "%scriptdir%\dist"
rmdir /s /q "%scriptdir%\build"
rmdir /s /q "%venvdir%"
rem Pause to keep the console window open for viewing output
pause