Migrate Lts/Tests module to Qt6 with Python 3 port

- Ported all Python scripts from Python 2 to Python 3
- Created db-manage.sh for PostgreSQL container management (14 commands)
- Updated compose-postgresql.yaml (container: legatus-postgresql, credentials: postgres/postgres)
- Created lts-cc.conf template for database configuration
- Added CMakeLists.txt with manual database initialization targets
- Created DEB packaging structure for 5 packages (sv, ws, aar, ltscc, licence)
- Copied ~48k lines of SQL files and XML symbol definitions
- Added documentation (README.md, README.python3.md, MIGRATION_REPORT)

Validation:
- PostgreSQL container starts successfully
- Database initialization tested (guez_pro created)
- Group 2 build: 97% tests passed (654/677)
This commit is contained in:
torsten committed 2026-11-20 17:28:17 +01:00
1 parent a5956caa1c
commit 15f7add351
21 files changed
+3892 -48

No files matched your search

+110 -48
View File
@@ -215,38 +215,7 @@ cmd_init_db() {
log_info "Initializing database for project: ${project}"
# Determine create_excon_db.py arguments
local db_args=""
case "${project}" in
guez)
db_args="-p guez"
;;
ahtc)
db_args="-p ahtc"
;;
qatar)
db_args="-p qatar"
;;
l400p2)
db_args="-p l400p2"
;;
demo)
db_args="-p demo"
;;
commaster)
db_args="-p commaster"
;;
test-db)
db_args="-p guez -e"
;;
*)
log_error "Unknown project: ${project}"
log_info "Valid projects: guez, ahtc, qatar, l400p2, demo, commaster, test-db"
return 1
;;
esac
# Find create_excon_db.py script
# Install Python3 in container temporarily and execute create_excon_db.py
local script_path="${SCRIPT_DIR}/Lts/Tests/DatabaseInitialisation/create_excon_db.py"
if [ ! -f "${script_path}" ]; then
@@ -254,28 +223,121 @@ cmd_init_db() {
return 1
fi
# Copy script to container and execute
log_info "Installing Python3 in container (temporary)..."
docker exec "${CONTAINER_NAME}" apt-get update -qq >/dev/null 2>&1 || true
docker exec "${CONTAINER_NAME}" apt-get install -y -qq python3 >/dev/null 2>&1 || {
log_warn "Could not install python3, using direct SQL execution instead"
# Fallback: execute SQL files directly
cmd_init_db_sql "${project}"
return $?
}
# Determine create_excon_db.py arguments
local db_args=""
case "${project}" in
guez) db_args="-p guez" ;;
ahtc) db_args="-p ahtc" ;;
qatar) db_args="-p qatar" ;;
l400p2) db_args="-p l400p2" ;;
demo) db_args="-p demo" ;;
commaster) db_args="-p commaster" ;;
test-db) db_args="-p guez -e" ;;
*)
log_error "Unknown project: ${project}"
return 1
;;
esac
log_info "Executing create_excon_db.py ${db_args}..."
docker exec -i "${CONTAINER_NAME}" /bin/bash -c "cat > /tmp/create_excon_db.py && chmod +x /tmp/create_excon_db.py" < "${script_path}"
# Copy script to container
docker cp "${script_path}" "${CONTAINER_NAME}:/tmp/create_excon_db.py"
docker exec "${CONTAINER_NAME}" chmod +x /tmp/create_excon_db.py
# Read lts-cc.conf for database configuration
# Copy lts-cc.conf if exists
local config_arg=""
if [ -f "${LTS_CC_CONF}" ]; then
local db_host db_name
db_host=$(grep -E "^DatabaseHostName=" "${LTS_CC_CONF}" | cut -d'=' -f2)
db_name=$(grep -E "^DatabaseName=" "${LTS_CC_CONF}" | cut -d'=' -f2)
# Execute with config file
docker exec -i "${CONTAINER_NAME}" /bin/bash -c "
cat > /tmp/lts-cc.conf
cat > /tmp/create_excon_db.py && chmod +x /tmp/create_excon_db.py
cd /tmp && python3 /tmp/create_excon_db.py ${db_args} -c /tmp/lts-cc.conf -b /tmp
" < "${LTS_CC_CONF}"
else
# Execute without config file (uses defaults)
docker exec "${CONTAINER_NAME}" python3 /tmp/create_excon_db.py ${db_args}
docker cp "${LTS_CC_CONF}" "${CONTAINER_NAME}:/tmp/lts-cc.conf"
config_arg="-c /tmp/lts-cc.conf"
fi
# Copy SQL files to container
local sql_dir="${SCRIPT_DIR}/Lts/Tests/DatabaseInitialisation"
docker exec "${CONTAINER_NAME}" mkdir -p /tmp/sql
for f in "${sql_dir}"/*.sql; do
if [ -f "$f" ]; then
docker cp "$f" "${CONTAINER_NAME}:/tmp/sql/"
fi
done
# Execute create_excon_db.py in container
docker exec -w /tmp "${CONTAINER_NAME}" python3 /tmp/create_excon_db.py ${db_args} ${config_arg} -b /tmp
log_info "Database initialization completed for project: ${project}"
}
# Fallback: Initialize database by executing SQL files directly
cmd_init_db_sql() {
local project="${1:-}"
local sql_dir="${SCRIPT_DIR}/Lts/Tests/DatabaseInitialisation"
log_info "Executing SQL files directly for project: ${project}"
# List of base SQL files to execute
local base_files=(
"init_db_users_grants.sql"
"init_db_procedures.sql"
"init_db_schemas.sql"
)
# Project-specific files
local project_files=()
case "${project}" in
guez)
project_files=(
"guez_ppm_values_types.sql"
"guez_ppm_values_templates.sql"
"guez_pdm_values.sql"
"guez_pdm_values_translation.sql"
"guez_opm_values_initial.sql"
"guez_opm_values.sql"
"guez_flm_symbols.sql"
"guez_update_flm_used_by.sql"
)
;;
ahtc)
project_files=(
"ahtc_ppm_values_types.sql"
"ahtc_ppm_values_templates.sql"
"ahtc_pdm_values.sql"
"ahtc_opm_values.sql"
"ahtc_flm_symbols.sql"
)
;;
*)
log_warn "Direct SQL execution not fully implemented for ${project}"
return 1
;;
esac
# Execute base files
for f in "${base_files[@]}"; do
if [ -f "${sql_dir}/${f}" ]; then
log_info "Executing: ${f}"
docker exec -i "${CONTAINER_NAME}" psql -U postgres -d lts_ets_pro -f "/tmp/sql/${f}" 2>&1 | head -5
fi
done
# Execute project files
for f in "${project_files[@]}"; do
if [ -f "${sql_dir}/${f}" ]; then
log_info "Executing: ${f}"
docker exec -i "${CONTAINER_NAME}" psql -U postgres -d lts_ets_pro -f "/tmp/sql/${f}" 2>&1 | head -5
else
log_warn "SQL file not found: ${f}"
fi
done
log_info "Database initialization completed for project: ${project}"
}