diff --git a/pyproject.toml b/pyproject.toml index d84c7ce..877c05b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "wce-crm" -version = "0.1.1dev2" +version = "0.1.1dev4" description = "GUI for CRM of NAFKA project with WCE" authors = [ {name = "d-opt GmbH, resp. Florian Förster", email = "f.foerster@d-opt.com"}, @@ -71,7 +71,7 @@ directory = "reports/coverage" [tool.bumpversion] -current_version = "0.1.1dev2" +current_version = "0.1.1dev4" parse = """(?x) (?P0|[1-9]\\d*)\\. (?P0|[1-9]\\d*)\\. diff --git a/scripts/Launch_App_Fallback.bat b/scripts/Launch_App_Fallback.bat new file mode 100644 index 0000000..48e2d41 --- /dev/null +++ b/scripts/Launch_App_Fallback.bat @@ -0,0 +1,6 @@ +@echo off +:: 1. Safely navigate to the exact folder this batch file is sitting in +cd /d "%~dp0" + +:: 2. Launch the app in the background and instantly close the command prompt +start "" "python\pythonw.exe" -m my_package.gui \ No newline at end of file diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 555c837..b66bc4e 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -19,6 +19,20 @@ if ($? -eq $false){ } Write-Output "Deleted outstanding artifacts successfully" + +Write-Output "Create data folder..." +$pattern = "dopt_nafka_wce-crm_v*" +$data_folder = Join-Path -Path $ENV_PATH -ChildPath 'data' + +if (-not (Test-Path -Path $data_folder)){ + Write-Output "[PWSH] Data path not existing. Create..." + New-Item -Path $data_folder -ItemType Directory +} +else { + Write-Output "Data path already exists." +} + + Write-Output "Building package..." .\scripts\publish.ps1 if ($? -eq $false){ @@ -56,17 +70,6 @@ if ($? -eq $false){ } Write-Output "Successfully installed package" -# copy CLI file -# TODO add startup file -# Write-Output "Copying CLI script file..." -# $cli_path = Join-Path -Path $SRC_PATH -ChildPath 'cli.py' -# Copy-Item -Path $cli_path -Destination $PY_PATH -Force -# if ($? -eq $false){ -# Write-Output "[PWSH] Exiting script because there were errors while copying the CLI script file" -# Exit -# } -# Write-Output "Copied CLI script file successfully" - # copy database file Write-Output "Copying database files..." $copy_file = Join-Path -Path $SRC_PATH -ChildPath 'data/db/wce_grunderfassung.db' @@ -97,18 +100,12 @@ Write-Output "Copied ENV file successfully" # copy startup script files Write-Output "Copying startup scripts..." -$copy_file = Join-Path -Path $SRC_PATH -ChildPath 'scripts/start.*' +$copy_file = Join-Path -Path $SRC_PATH -ChildPath 'scripts/start.bat' Copy-Item -Path $copy_file -Destination $ENV_PATH -Force if ($? -eq $false){ Write-Output "[PWSH] Exiting script because there were errors while copying startup scripts" Exit } -# $copy_file = Join-Path -Path $SRC_PATH -ChildPath 'data/db/wce_crm.db' -# Copy-Item -Path $copy_file -Destination $dest_file -Force -# if ($? -eq $false){ -# Write-Output "[PWSH] Exiting script because there were errors while copying database 'CRM'" -# Exit -# } Write-Output "Copied startup scripts successfully" diff --git a/scripts/start.bat b/scripts/start.bat index e0b18c2..be1dd97 100644 --- a/scripts/start.bat +++ b/scripts/start.bat @@ -1,3 +1,7 @@ @echo off -cd /d "%~dp0" -start "" "python\pythonw.exe" -m wce_crm.gui \ No newline at end of file +:: 1. Navigate directly into the python environment folder +cd /d "%~dp0python" +@REM cd /d "python" +@REM python.exe -m my_package.gui +:: 2. Launch pythonw silently +start "" "pythonw.exe" -m wce_crm.gui \ No newline at end of file diff --git a/scripts/start.vbs b/scripts/start.vbs index 3126d6f..4b9cd24 100644 --- a/scripts/start.vbs +++ b/scripts/start.vbs @@ -1,13 +1,17 @@ Set WshShell = CreateObject("WScript.Shell") Set FSO = CreateObject("Scripting.FileSystemObject") -strScriptDir = FSO.GetParentFolderName(WScript.ScriptFullName) -WshShell.CurrentDirectory = strScriptDir +' 1. Get the exact path to the python_env folder +strEnvDir = FSO.GetParentFolderName(WScript.ScriptFullName) & "\python" -pythonExe = strScriptDir & "\python\python.exe" +' 2. Set the working directory (crucial so pythonw.exe finds its DLLs) +WshShell.CurrentDirectory = strEnvDir -' Use cmd.exe /c (close when done) as a trusted bridge to launch the module -runCommand = "cmd.exe /c " & Chr(34) & pythonExe & Chr(34) & " -m wce_crm.gui" +' 3. Get the ABSOLUTE path to the executable, not just the file name +pythonExe = strEnvDir & "\pythonw.exe" -' Set back to 0 (Hidden). +' 4. Build the command using the absolute path +runCommand = Chr(34) & pythonExe & Chr(34) & " -m wce_crm.gui" + +' 5. Run it completely hidden WshShell.Run runCommand, 0, False \ No newline at end of file