From 0f4dc32cd9f7784ace6028f6e4df705b6382d4ea Mon Sep 17 00:00:00 2001 From: Brent Vollebregt Date: Sat, 1 Jun 2024 23:09:30 +1200 Subject: [PATCH] #486 Initial setup --- auto_py_to_exe/ui.py | 8 ++++++++ auto_py_to_exe/web/index.html | 1 + auto_py_to_exe/web/js/configuration.js | 20 ++++++++++++++++++++ auto_py_to_exe/web/js/constants.js | 2 +- auto_py_to_exe/web/js/utils.js | 4 ++++ 5 files changed, 34 insertions(+), 1 deletion(-) diff --git a/auto_py_to_exe/ui.py b/auto_py_to_exe/ui.py index e2d4d2ea..7b2760b3 100644 --- a/auto_py_to_exe/ui.py +++ b/auto_py_to_exe/ui.py @@ -126,6 +126,14 @@ def is_file_an_ico(file_path): return False +@eel.expose +def convert_path_to_absolute(path: str) -> str: + """Converts a path to an absolute path if it exists. If it doesn't exist, returns the path as is.""" + if not os.path.exists(path): + return path + return os.path.abspath(path) + + @eel.expose def import_configuration(): """Get configuration data from a file""" diff --git a/auto_py_to_exe/web/index.html b/auto_py_to_exe/web/index.html index dc02f7f5..3782860d 100644 --- a/auto_py_to_exe/web/index.html +++ b/auto_py_to_exe/web/index.html @@ -20,6 +20,7 @@ ask_files: () => [], ask_folder: () => '', is_file_an_ico: (file_path) => null, + convert_path_to_absolute: (path) => '', open_output_in_explorer: (output_directory, input_filename, is_one_file) => {}, will_packaging_overwrite_existing: (file_path, manual_name, one_file, output_folder) => true, package: (command, non_pyinstaller_options) => {}, diff --git a/auto_py_to_exe/web/js/configuration.js b/auto_py_to_exe/web/js/configuration.js index 1ce8f296..1d5c7d77 100644 --- a/auto_py_to_exe/web/js/configuration.js +++ b/auto_py_to_exe/web/js/configuration.js @@ -26,6 +26,26 @@ const getCurrentConfiguration = () => { } }); + // Convert all relative paths to absolute paths + for (const c of currentConfiguration) { + const option = options.find((o) => o.dest === c.optionDest); + if (option === undefined) { + continue; + } + + if ([OPTION_INPUT_VALUE_FILE, OPTION_INPUT_VALUE_DIRECTORY].some((v) => option.allowedInputValues.includes(v))) { + c.valueNew = convertPathToAbsolute(c.value); + } + if ( + [OPTION_INPUT_VALUE_DOUBLE_FILE_DEST, OPTION_INPUT_VALUE_DOUBLE_DIRECTORY_DEST].some((v) => + option.allowedInputValues.includes(v) + ) + ) { + const [src, dest] = c.value.split(pathSeparator); + c.valueNew = `${convertPathToAbsolute(src)}${pathSeparator}${dest}`; + } + } + return currentConfiguration; }; diff --git a/auto_py_to_exe/web/js/constants.js b/auto_py_to_exe/web/js/constants.js index 63b3b467..196129a4 100644 --- a/auto_py_to_exe/web/js/constants.js +++ b/auto_py_to_exe/web/js/constants.js @@ -2,7 +2,7 @@ const options_ignored = ['help']; const options_static = ['filenames', 'onefile', 'console', 'icon_file', 'datas']; const options_overridden = ['specpath', 'distpath', 'workpath', 'noconfirm']; -const options_inputTypeFile = ['runtime_hooks', 'version_file', 'manifest', 'resources', 'splash']; +const options_inputTypeFile = ['runtime_hooks', 'version_file', 'manifest', 'resources', 'splash', 'entitlements_file']; const options_inputTypeDirectory = ['upx_dir', 'pathex', 'hookspath']; const options_inputTypeDoubleFileDest = ['datas', 'binaries']; const options_inputTypeDoubleDirectoryDest = ['datas']; diff --git a/auto_py_to_exe/web/js/utils.js b/auto_py_to_exe/web/js/utils.js index b875300d..d350c052 100644 --- a/auto_py_to_exe/web/js/utils.js +++ b/auto_py_to_exe/web/js/utils.js @@ -37,6 +37,10 @@ const isFileAnIco = async (file_path) => { return await eel.is_file_an_ico(file_path)(); }; +const convertPathToAbsolute = async (path) => { + return await eel.convert_path_to_absolute(path)(); +}; + const chooseOptionString = (optionStrings) => { // Try not to use compressed flags if (optionStrings[0].length === 2 && optionStrings.length > 1) {