bat Dateien mit Errorlevel versehen. manage_interpreter.bat vereinfacht. Nur noch eine Umgebungsvar für den Python Interpreter im Netzwerk.

This commit is contained in:
2026-01-28 20:20:20 +01:00
parent e214e9d21e
commit e087b65359
14 changed files with 353 additions and 79 deletions
+14 -3
View File
@@ -1,4 +1,15 @@
@echo off @echo off
CALL manage_interpreter.bat activate_interpreter CALL manage_interpreter.bat activate
python %PROJECT_LIB%\create_example.py %* if errorlevel 1 (
CALL manage_interpreter.bat deactivate_interpreter echo ERROR: Failed to activate Python environment
exit /b 1
)
pushd "%PROJECT%"
"%VIRTUAL_ENV%\Scripts\python.exe" -m lib.create_example %*
set PYTHON_EXIT=%ERRORLEVEL%
popd
CALL manage_interpreter.bat deactivate
exit /b %PYTHON_EXIT%
+14 -3
View File
@@ -1,4 +1,15 @@
@echo off @echo off
CALL manage_interpreter.bat activate_interpreter CALL manage_interpreter.bat activate
python %PROJECT_LIB%\create_numbers.py %* if errorlevel 1 (
CALL manage_interpreter.bat deactivate_interpreter echo ERROR: Failed to activate Python environment
exit /b 1
)
pushd "%PROJECT%"
"%VIRTUAL_ENV%\Scripts\python.exe" -m lib.create_numbers %*
set PYTHON_EXIT=%ERRORLEVEL%
popd
CALL manage_interpreter.bat deactivate
exit /b %PYTHON_EXIT%
+14 -3
View File
@@ -1,4 +1,15 @@
@echo off @echo off
CALL manage_interpreter.bat activate_interpreter CALL manage_interpreter.bat activate
python %PROJECT_LIB%\drawdxf.py %* if errorlevel 1 (
CALL manage_interpreter.bat deactivate_interpreter echo ERROR: Failed to activate Python environment
exit /b 1
)
pushd "%PROJECT%"
"%VIRTUAL_ENV%\Scripts\python.exe" -m lib.drawdxf %*
set PYTHON_EXIT=%ERRORLEVEL%
popd
CALL manage_interpreter.bat deactivate
exit /b %PYTHON_EXIT%
+14 -3
View File
@@ -1,4 +1,15 @@
@echo off @echo off
CALL manage_interpreter.bat activate_interpreter CALL manage_interpreter.bat activate
python %PROJECT_LIB%\getpositions.py %* if errorlevel 1 (
CALL manage_interpreter.bat deactivate_interpreter echo ERROR: Failed to activate Python environment
exit /b 1
)
pushd "%PROJECT%"
"%VIRTUAL_ENV%\Scripts\python.exe" -m lib.getpositions %*
set PYTHON_EXIT=%ERRORLEVEL%
popd
CALL manage_interpreter.bat deactivate
exit /b %PYTHON_EXIT%
+26 -21
View File
@@ -1,30 +1,35 @@
@echo off @echo off
CALL setenv.bat CALL setenv.bat
IF DEFINED NETWORK_INTERPRETER_PATH (
goto %~1_network
IF /I "%1"=="activate" GOTO activate
IF /I "%1"=="deactivate" GOTO deactivate
IF /I "%1"=="activate_interpreter" GOTO activate
IF /I "%1"=="deactivate_interpreter" GOTO deactivate
GOTO :eof
:activate
REM Interpreter wählen
IF DEFINED NETWORK_PYTHON (
SET PYTHON_EXE=%NETWORK_PYTHON%\python.exe
) ELSE ( ) ELSE (
goto %~1_local SET PYTHON_EXE=python
) )
:activate_interpreter_local REM venv sicherstellen
IF NOT EXIST %PROJECT%\.venv CALL %PROJECT_BIN%\install_py.bat IF NOT EXIST "%PROJECT%\.venv" (
CALL %PROJECT%\.venv\Scripts\activate.bat "%PYTHON_EXE%" -m venv "%PROJECT%\.venv"
goto :eof )
:deactivate_interpreter_local REM venv aktivieren
deactivate CALL "%PROJECT%\.venv\Scripts\activate.bat"
goto :eof
:activate_interpreter_network REM Interpreter festnageln
SET OLD_PATH=%PATH% SET VIRTUAL_ENV_PYTHON=%PYTHON_EXE%
SET PATH=%NETWORK_INTERPRETER_PATH%;%PATH% GOTO :eof
CALL %PROJECT%\.venv\Scripts\activate.bat
goto :eof
:deactivate_interpreter_network
SET PATH=%OLD_PATH% :deactivate
SET OLD_PATH= CALL "%PROJECT%\.venv\Scripts\deactivate.bat"
SET NETWORK_INTERPRETER_PATH= SET VIRTUAL_ENV_PYTHON=
CALL %PROJECT%\.venv\Scripts\deactivate.bat GOTO :eof
goto :eof
+14 -3
View File
@@ -1,4 +1,15 @@
@echo off @echo off
CALL manage_interpreter.bat activate_interpreter CALL manage_interpreter.bat activate
python %PROJECT_LIB%\portalexport.py %* if errorlevel 1 (
CALL manage_interpreter.bat deactivate_interpreter echo ERROR: Failed to activate Python environment
exit /b 1
)
pushd "%PROJECT%"
"%VIRTUAL_ENV%\Scripts\python.exe" -m lib.portalexport %*
set PYTHON_EXIT=%ERRORLEVEL%
popd
CALL manage_interpreter.bat deactivate
exit /b %PYTHON_EXIT%
+14 -3
View File
@@ -1,4 +1,15 @@
@echo off @echo off
CALL manage_interpreter.bat activate_interpreter CALL manage_interpreter.bat activate
python %PROJECT_LIB%\routing.py %* if errorlevel 1 (
CALL manage_interpreter.bat deactivate_interpreter echo ERROR: Failed to activate Python environment
exit /b 1
)
pushd "%PROJECT%"
"%VIRTUAL_ENV%\Scripts\python.exe" -m lib.routing %*
set PYTHON_EXIT=%ERRORLEVEL%
popd
CALL manage_interpreter.bat deactivate
exit /b %PYTHON_EXIT%
+14 -3
View File
@@ -65,12 +65,23 @@ echo Test-Parameter: %TEST_PARAMS%
echo ============================================================================ echo ============================================================================
echo. echo.
REM Wechsle ins Projektverzeichnis und führe run_tests.py aus REM Python-Umgebung aktivieren
cd /d "%PROJECT%" CALL "%PROJECT_BIN%\manage_interpreter.bat" activate
python "%PROJECT_LIB%\run_tests.py" %TEST_PARAMS% if errorlevel 1 (
echo ERROR: Failed to activate Python environment
exit /b 1
)
REM Wechsle ins Projektverzeichnis und führe run_tests.py aus
pushd "%PROJECT%"
"%VIRTUAL_ENV%\Scripts\python.exe" -m lib.run_tests %TEST_PARAMS%
set TEST_RESULT=%ERRORLEVEL% set TEST_RESULT=%ERRORLEVEL%
popd
REM Python-Umgebung deaktivieren
CALL "%PROJECT_BIN%\manage_interpreter.bat" deactivate
echo. echo.
echo ============================================================================ echo ============================================================================
if %TEST_RESULT% EQU 0 ( if %TEST_RESULT% EQU 0 (
+10 -6
View File
@@ -4,24 +4,28 @@ REM Calls run_tests.py to execute all tests
call %~dp0setenv.bat call %~dp0setenv.bat
CALL manage_interpreter.bat activate_interpreter CALL manage_interpreter.bat activate
if %ERRORLEVEL% NEQ 0 ( if errorlevel 1 (
echo. echo.
echo Failed to activate the Python interpreter! echo Failed to activate the Python interpreter!
pause pause
exit /B 1 exit /B 1
) )
python %PROJECT_LIB%\run_tests.py %* pushd "%PROJECT%"
if %ERRORLEVEL% NEQ 0 ( "%VIRTUAL_ENV%\Scripts\python.exe" -m lib.run_tests %*
set PYTHON_EXIT=%ERRORLEVEL%
popd
CALL manage_interpreter.bat deactivate
if %PYTHON_EXIT% NEQ 0 (
echo. echo.
echo Tests failed! echo Tests failed!
CALL manage_interpreter.bat deactivate_interpreter
exit /B 1 exit /B 1
) else ( ) else (
echo. echo.
echo All tests passed! echo All tests passed!
CALL manage_interpreter.bat deactivate_interpreter
exit /B 0 exit /B 0
) )
+5 -1
View File
@@ -2,7 +2,10 @@
REM falls Umlaute in den Pfaden sind: REM falls Umlaute in den Pfaden sind:
chcp 65001 > nul chcp 65001 > nul
set PROJECT=c:\kabellaengen REM ~dp0 steht für das Verzeichnis, in der diese Datei liegt
pushd %~dp0\..
set PROJECT=%cd%
set PROJECT_BIN=%PROJECT%\bin set PROJECT_BIN=%PROJECT%\bin
set PROJECT_CFG=%PROJECT%\cfg set PROJECT_CFG=%PROJECT%\cfg
set PROJECT_DOC=%PROJECT%\doc set PROJECT_DOC=%PROJECT%\doc
@@ -32,6 +35,7 @@ if exist "%~dp0_setenv.bat" (
REM Prüfe ob PATH bereits erweitert wurde REM Prüfe ob PATH bereits erweitert wurde
set PATH=%PROJECT_BIN%;%PATH% set PATH=%PROJECT_BIN%;%PATH%
REM set NETWORK_PYTHON=TO_BE_SET
popd popd
+11 -1
View File
@@ -1,6 +1,8 @@
#!/bin/bash #!/bin/bash
export PROJECT=$HOME/dxf-calculator/kabellaengen # Determine the project directory dynamically
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
export PROJECT="$(cd "$SCRIPT_DIR/.." && pwd)"
export PROJECT_BIN="$PROJECT/bin" export PROJECT_BIN="$PROJECT/bin"
export PROJECT_CFG="$PROJECT/cfg" export PROJECT_CFG="$PROJECT/cfg"
export PROJECT_DOC="$PROJECT/doc" export PROJECT_DOC="$PROJECT/doc"
@@ -8,6 +10,8 @@ export PROJECT_LIB="$PROJECT/lib"
export PROJECT_DATA="$PROJECT/data" export PROJECT_DATA="$PROJECT/data"
export PROJECT_WORK="$PROJECT/work" export PROJECT_WORK="$PROJECT/work"
export PROJECT_TEST="$PROJECT/testdata" export PROJECT_TEST="$PROJECT/testdata"
export PROJECT_LOG="$PROJECT/logs"
export PROJECT_TRANSLATION="$PROJECT/translation"
# Linux executable instead of Windows .exe # Linux executable instead of Windows .exe
export SIVAS_TEILESTAMM="/usr/local/bin/KSbExcelExportSivasTeilestamm" export SIVAS_TEILESTAMM="/usr/local/bin/KSbExcelExportSivasTeilestamm"
@@ -16,6 +20,9 @@ export SIVAS_EXCEL_EXPORT_DIR="$PROJECT_DATA"
# Create directories if they don't exist # Create directories if they don't exist
mkdir -p "$PROJECT/work" mkdir -p "$PROJECT/work"
mkdir -p "$PROJECT/data" mkdir -p "$PROJECT/data"
mkdir -p "$PROJECT/logs"
mkdir -p "$PROJECT/translation"
mkdir -p "$PROJECT/testdata"
# Samba shares (adjust mount points as needed) # Samba shares (adjust mount points as needed)
export PROJECT_IO_RESULTS=$PROJECT_WORK export PROJECT_IO_RESULTS=$PROJECT_WORK
@@ -24,3 +31,6 @@ export INSTALL_DIR="$HOME/kabeltool"
# Add project bin to PATH (only if not already added) # Add project bin to PATH (only if not already added)
export PATH="$PROJECT_BIN:$PATH" export PATH="$PROJECT_BIN:$PATH"
# Network Python interpreter (optional)
# export NETWORK_PYTHON=/path/to/network/python
+14 -3
View File
@@ -1,4 +1,15 @@
@echo off @echo off
CALL manage_interpreter.bat activate_interpreter CALL manage_interpreter.bat activate
python %PROJECT_LIB%\translate.py %* if errorlevel 1 (
CALL manage_interpreter.bat deactivate_interpreter echo ERROR: Failed to activate Python environment
exit /b 1
)
pushd "%PROJECT%"
"%VIRTUAL_ENV%\Scripts\python.exe" -m lib.translate %*
set PYTHON_EXIT=%ERRORLEVEL%
popd
CALL manage_interpreter.bat deactivate
exit /b %PYTHON_EXIT%
+142 -12
View File
@@ -38,7 +38,7 @@
"layer_name": "ILS_MOTOR", "layer_name": "ILS_MOTOR",
"direction": "LEFT_RIGHT", "direction": "LEFT_RIGHT",
"x": 800, "x": 800,
"y": 800, "y": 900,
"width": 4000, "width": 4000,
"height": 450, "height": 450,
"use_polyline": false "use_polyline": false
@@ -49,8 +49,8 @@
"kennzeichnung": "A01+UH00", "kennzeichnung": "A01+UH00",
"layer_name": "ILS_MOTOR", "layer_name": "ILS_MOTOR",
"direction": "LEFT_RIGHT", "direction": "LEFT_RIGHT",
"x": 450, "x": 400,
"y": 100, "y": 75,
"width": 1400, "width": 1400,
"height": 480, "height": 480,
"use_polyline": true "use_polyline": true
@@ -159,6 +159,136 @@
] ]
} }
] ]
},
"BG_Multi_Frames": {
"description": "Test-Szene mit drei Rechtecken für BG-1@@@ und BG-2@@@ Symbole mit mehreren Layern",
"ma_groups": [
{
"name": "BG-1@@_frame1",
"count": 1,
"layout_type": "single",
"base_x": 700,
"base_y": 700,
"spacing": 0
},
{
"name": "BG-1@@_frame2_1",
"count": 1,
"layout_type": "single",
"base_x": 3500,
"base_y": 2350,
"spacing": 0
},
{
"name": "BG-1@@_frame2_2",
"count": 1,
"layout_type": "single",
"base_x": 4800,
"base_y": 2400,
"spacing": 0
},
{
"name": "BG-1@@_frame2_3",
"count": 1,
"layout_type": "single",
"base_x": 6100,
"base_y": 2300,
"spacing": 0
},
{
"name": "MB-1@@_frame2_1",
"count": 1,
"layout_type": "single",
"base_x": 3500,
"base_y": 2800,
"spacing": 0
},
{
"name": "MB-1@@_frame2_2",
"count": 1,
"layout_type": "single",
"base_x": 4800,
"base_y": 2850,
"spacing": 0
},
{
"name": "MB-1@@_frame2_3",
"count": 1,
"layout_type": "single",
"base_x": 6100,
"base_y": 2750,
"spacing": 0
},
{
"name": "BG-2@@_frame3_1",
"count": 1,
"layout_type": "single",
"base_x": 3700,
"base_y": 700,
"spacing": 0
},
{
"name": "BG-2@@_frame3_2",
"count": 1,
"layout_type": "single",
"base_x": 5000,
"base_y": 700,
"spacing": 0
},
{
"name": "BG-2@@_frame3_3",
"count": 1,
"layout_type": "single",
"base_x": 6300,
"base_y": 700,
"spacing": 0
}
],
"renaming_frames": [
{
"comment": "Rahmen 1: Links unten - 1x BG-1@@@ (Polylinie)",
"name": "BG-1@@@",
"name2": "MB-1@@@",
"kennzeichnung": "",
"layer_name1": "ILS_Eingang",
"layer_name2": "ILS_Ausgang",
"direction": "LEFT_RIGHT",
"x": 300,
"y": 500,
"width": 1200,
"height": 500,
"use_polyline": true
},
{
"comment": "Rahmen 2: Rechts oben - 3x BG-1@@@ + 3x MB-1@@@ (Polylinie)",
"name": "BG-1@@@",
"name2": "MB-1@@@",
"kennzeichnung": "",
"layer_name1": "ILS_Eingang",
"layer_name2": "ILS_Ausgang",
"direction": "LEFT_RIGHT",
"x": 3000,
"y": 2000,
"width": 3600,
"height": 1000,
"use_polyline": true
},
{
"comment": "Rahmen 3: Rechts unten - 3x BG-2@@@ (normales Rechteck)",
"name": "BG-2@@@",
"name2": "MB-2@@@",
"kennzeichnung": "",
"layer_name1": "ILS_Eingang",
"layer_name2": "ILS_Ausgang",
"direction": "LEFT_RIGHT",
"x": 3200,
"y": 500,
"width": 3600,
"height": 500,
"use_polyline": false
}
]
} }
}, },
@@ -229,47 +359,47 @@
"_description": "ATTDEF Positionen im inneren Block RENAMER_ATTRIB_MULTI", "_description": "ATTDEF Positionen im inneren Block RENAMER_ATTRIB_MULTI",
"NAME1": { "NAME1": {
"x": 10, "x": 10,
"y": 80, "y": -10,
"height": 21.25 "height": 21.25
}, },
"NAME2": { "NAME2": {
"x": 10, "x": 10,
"y": 60, "y": -45,
"height": 21.25 "height": 21.25
}, },
"NAME3": { "NAME3": {
"x": 10, "x": 10,
"y": 40, "y": -80,
"height": 21.25 "height": 21.25
}, },
"KENNZEICHNUNG": { "KENNZEICHNUNG": {
"x": 10, "x": 10,
"y": 20, "y": -115,
"height": 21.25 "height": 21.25
}, },
"LAYER_NAME1": { "LAYER_NAME1": {
"x": 10, "x": 10,
"y": -20, "y": -150,
"height": 21.25 "height": 21.25
}, },
"LAYER_NAME2": { "LAYER_NAME2": {
"x": 10, "x": 10,
"y": -40, "y": -185,
"height": 21.25 "height": 21.25
}, },
"LAYER_NAME3": { "LAYER_NAME3": {
"x": 10, "x": 10,
"y": -60, "y": -220,
"height": 21.25 "height": 21.25
}, },
"DIRECTION": { "DIRECTION": {
"x": 10, "x": 10,
"y": -80, "y": -255,
"height": 21.25 "height": 21.25
}, },
"ID": { "ID": {
"x": 10, "x": 10,
"y": -100, "y": -290,
"height": 21.25 "height": 21.25
} }
} }
+47 -14
View File
@@ -405,7 +405,8 @@ class TestDataGenerator:
return attrib_block return attrib_block
def create_renamer_frame(self, insert_point, width, height, name, kennzeichnung, def create_renamer_frame(self, insert_point, width, height, name, kennzeichnung,
layer_name, direction, use_polyline=False, frame_type='MA'): layer_name, direction, use_polyline=False, frame_type='MA',
name2='', name3='', layer_name2='', layer_name3='', id_value=''):
""" """
Erstellt einen Renamer-Rahmen mit zweistufiger Block-Struktur auf Layer ILS_RENAMER Erstellt einen Renamer-Rahmen mit zweistufiger Block-Struktur auf Layer ILS_RENAMER
@@ -475,9 +476,18 @@ class TestDataGenerator:
'LAYER_NAME': layer_name, 'LAYER_NAME': layer_name,
'DIRECTION': direction 'DIRECTION': direction
}) })
else: # MULTI - würde später für BG/MG/POT verwendet else: # MULTI - für BG/MG/POT mit mehreren Layern
# Placeholder für Multi-Layer Frame attrib_blockref.add_auto_attribs({
pass 'NAME1': name,
'NAME2': name2,
'NAME3': name3,
'KENNZEICHNUNG': kennzeichnung,
'LAYER_NAME1': layer_name,
'LAYER_NAME2': layer_name2,
'LAYER_NAME3': layer_name3,
'DIRECTION': direction,
'ID': id_value
})
# Füge Block-Referenz im Modelspace ein # Füge Block-Referenz im Modelspace ein
blockref = self.msp.add_blockref( blockref = self.msp.add_blockref(
@@ -724,16 +734,39 @@ class TestDataGenerator:
) )
else: else:
# Standard Rectangle Frame # Standard Rectangle Frame
self.create_renamer_frame( # Prüfe ob es ein MULTI-Frame ist (NAME1/NAME2 statt NAME)
insert_point=(frame_config['x'], frame_config['y']), is_multi_frame = 'name2' in frame_config or 'layer_name1' in frame_config
width=frame_config['width'],
height=frame_config['height'], if is_multi_frame:
name=frame_config['name'], # MULTI-Frame (BG, MG, POT mit mehreren Layern)
kennzeichnung=frame_config['kennzeichnung'], self.create_renamer_frame(
layer_name=frame_config['layer_name'], insert_point=(frame_config['x'], frame_config['y']),
direction=frame_config['direction'], width=frame_config['width'],
use_polyline=frame_config.get('use_polyline', False) height=frame_config['height'],
) name=frame_config.get('name', ''),
kennzeichnung=frame_config.get('kennzeichnung', ''),
layer_name=frame_config.get('layer_name1', ''),
direction=frame_config.get('direction', ''),
use_polyline=frame_config.get('use_polyline', False),
frame_type='MULTI',
name2=frame_config.get('name2', ''),
name3=frame_config.get('name3', ''),
layer_name2=frame_config.get('layer_name2', ''),
layer_name3=frame_config.get('layer_name3', ''),
id_value=frame_config.get('id', '')
)
else:
# MA-Frame (einfacher Frame)
self.create_renamer_frame(
insert_point=(frame_config['x'], frame_config['y']),
width=frame_config['width'],
height=frame_config['height'],
name=frame_config['name'],
kennzeichnung=frame_config['kennzeichnung'],
layer_name=frame_config['layer_name'],
direction=frame_config['direction'],
use_polyline=frame_config.get('use_polyline', False)
)
# Prüfe ob alle generierten Symbole in einem Renamer-Frame liegen # Prüfe ob alle generierten Symbole in einem Renamer-Frame liegen
self._validate_symbols_in_frames(scene) self._validate_symbols_in_frames(scene)