diff --git a/scripts/build.ps1 b/scripts/build.ps1 index ec3ba0c..555c837 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -1,5 +1,10 @@ +[CmdletBinding()] +Param( + [switch]$NoPackaging +) + $DEPLOYMENT_PATH = 'B:\deployments\WCE-NAFKA' -$ENV_PATH = 'B:\deployments\EKF-Diagnostics\dopt_nafka_wce-crm' +$ENV_PATH = 'B:\deployments\WCE-NAFKA\dopt_nafka_wce-crm' $PY_PATH = Join-Path -Path $ENV_PATH -ChildPath 'python' $SRC_PATH = (Get-Location).Path @@ -62,16 +67,49 @@ Write-Output "Successfully installed package" # } # 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' +$dest_file = Join-Path -Path $ENV_PATH -ChildPath 'data' +Copy-Item -Path $copy_file -Destination $dest_file -Force +if ($? -eq $false){ + Write-Output "[PWSH] Exiting script because there were errors while copying database 'Grunderfassung'" + 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 database files successfully" + # copy .env file -Write-Output "Copying model weight files..." +Write-Output "Copying ENV file..." $env_file = Join-Path -Path $SRC_PATH -ChildPath 'deployment/.env' $env_dest_path = Join-Path -Path $PY_PATH -ChildPath '.env' Copy-Item -Path $env_file -Destination $env_dest_path -Force if ($? -eq $false){ - Write-Output "[PWSH] Exiting script because there were errors while copying the model weight files" + Write-Output "[PWSH] Exiting script because there were errors while copying ENV file" Exit } -Write-Output "Copied model weight files successfully" +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-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" # env preparation @@ -88,6 +126,13 @@ if ($? -eq $false){ } Write-Output "Successfully prepared environment with cleanup and pre-compilation" +if ($NoPackaging) { + Write-Output "[PWSH] No packaging selected. Exit..." + Set-Location $SRC_PATH + Exit +} + + Write-Output "Get version string..." $pyproject = Get-Content $SRC_PATH\pyproject.toml -Raw diff --git a/scripts/start.bat b/scripts/start.bat new file mode 100644 index 0000000..e0b18c2 --- /dev/null +++ b/scripts/start.bat @@ -0,0 +1,3 @@ +@echo off +cd /d "%~dp0" +start "" "python\pythonw.exe" -m wce_crm.gui \ No newline at end of file diff --git a/scripts/start.vbs b/scripts/start.vbs new file mode 100644 index 0000000..3126d6f --- /dev/null +++ b/scripts/start.vbs @@ -0,0 +1,13 @@ +Set WshShell = CreateObject("WScript.Shell") +Set FSO = CreateObject("Scripting.FileSystemObject") + +strScriptDir = FSO.GetParentFolderName(WScript.ScriptFullName) +WshShell.CurrentDirectory = strScriptDir + +pythonExe = strScriptDir & "\python\python.exe" + +' 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" + +' Set back to 0 (Hidden). +WshShell.Run runCommand, 0, False \ No newline at end of file