1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-11-23 02:36:41 +00:00

Add config.ini to remember output folder

This commit is contained in:
D-Pyro 2024-01-10 19:34:34 -05:00
parent 62c29308db
commit b05c068e40
4 changed files with 73 additions and 25 deletions

2
host/config.ini Normal file
View file

@ -0,0 +1,2 @@
[Directories]
Output = /path/to/directory

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.

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