diff --git a/Simbriefimport.py b/Simbriefimport.py index dc63300..b3a98e2 100644 --- a/Simbriefimport.py +++ b/Simbriefimport.py @@ -1,4 +1,5 @@ #V0.1.1b @PC +from __future__ import annotations import requests import json from pathlib import Path @@ -12,6 +13,76 @@ import logging from logging.handlers import RotatingFileHandler from version import VERSION +import subprocess + +VERSION = "0.1.1" + +APP_NAME = "Simbriefimport" +COMPANY = "Carsten" +COPYRIGHT = "© 2025 Carsten" + +VERSION_INFO_FILE = Path("version_info.txt") + + + +def _git_build_number() -> int: + try: + out = subprocess.check_output( + ["git", "rev-list", "--count", "HEAD"], + stderr=subprocess.DEVNULL + ) + return int(out.decode().strip()) + except Exception: + return 0 + + +def ensure_version_info(force: bool = False) -> str: + """ + Erzeugt version_info.txt für PyInstaller. + Gibt die Textversion zurück, z.B. '1.4.0.237'. + """ + build = _git_build_number() + major, minor, patch = map(int, VERSION.split(".")) + filevers = f"{major},{minor},{patch},{build}" + textvers = f"{VERSION}.{build}" + + if VERSION_INFO_FILE.exists() and not force: + return textvers + + content = f"""VSVersionInfo( + ffi=FixedFileInfo( + filevers=({filevers}), + prodvers=({filevers}), + mask=0x3f, + flags=0x0, + OS=0x40004, + fileType=0x1, + subtype=0x0, + date=(0,0) + ), + kids=[ + StringFileInfo( + [ + StringTable( + '040904B0', + [ + StringStruct('CompanyName', '{COMPANY}'), + StringStruct('FileDescription', '{APP_NAME}'), + StringStruct('ProductName', '{APP_NAME}'), + StringStruct('InternalName', '{APP_NAME}'), + StringStruct('OriginalFilename', '{APP_NAME}.exe'), + StringStruct('FileVersion', '{textvers}'), + StringStruct('ProductVersion', '{textvers}'), + StringStruct('LegalCopyright', '{COPYRIGHT}') + ] + ) + ] + ) + ] +) +""" + VERSION_INFO_FILE.write_text(content, encoding="utf-8") + return textvers def get_build(): try: import subprocess @@ -367,6 +438,9 @@ def delete(pfad_ogg): pfad_ogg.unlink() logging.info("Datei gelöscht: %s", pfad_ogg) return None + + + host = os.getcwd() Pfad = os.getcwd() + '/Announcements/' _airports_cache = None @@ -545,3 +619,6 @@ logging.info(" F E R T S C H ") logging.info("--------------------------------------------------") logging.info("Version: %s.%s", VERSION, get_build()) +#VERSION = str("Version: %s.%s", VERSION, get_build()) +ver = ensure_version_info() # erzeugt version_info.txt im Dev-Workspace +logging.info("Programmversion: %s", ver) diff --git a/make_version_info.py b/make_version_info.py new file mode 100644 index 0000000..ff14f32 --- /dev/null +++ b/make_version_info.py @@ -0,0 +1,84 @@ +from pathlib import Path +import subprocess +from version import VERSION + +# ========================= +# Konfiguration +# ========================= +APP_NAME = "Simbriefimport" +COMPANY = "Carsten" +COPYRIGHT = "© 2025 Carsten" + +OUTPUT_FILE = Path("version_info.txt") + + +def get_build_number() -> int: + """ + Ermittelt die Buildnummer aus Git (Commit-Zähler). + Fällt sauber auf 0 zurück, wenn Git nicht verfügbar ist. + """ + try: + out = subprocess.check_output( + ["git", "rev-list", "--count", "HEAD"], + stderr=subprocess.DEVNULL + ) + return int(out.decode().strip()) + except Exception: + return 0 + + +def main(): + build = get_build_number() + + try: + major, minor, patch = map(int, VERSION.split(".")) + except ValueError: + raise RuntimeError( + f"VERSION '{VERSION}' muss dem Schema Major.Minor.Patch entsprechen" + ) + + filevers = f"{major},{minor},{patch},{build}" + textvers = f"{VERSION}.{build}" + + content = f"""VSVersionInfo( + ffi=FixedFileInfo( + filevers=({filevers}), + prodvers=({filevers}), + mask=0x3f, + flags=0x0, + OS=0x40004, + fileType=0x1, + subtype=0x0, + date=(0,0) + ), + kids=[ + StringFileInfo( + [ + StringTable( + '040904B0', + [ + StringStruct('CompanyName', '{COMPANY}'), + StringStruct('FileDescription', '{APP_NAME}'), + StringStruct('ProductName', '{APP_NAME}'), + StringStruct('InternalName', '{APP_NAME}'), + StringStruct('OriginalFilename', '{APP_NAME}.exe'), + StringStruct('FileVersion', '{textvers}'), + StringStruct('ProductVersion', '{textvers}'), + StringStruct('LegalCopyright', '{COPYRIGHT}') + ] + ) + ] + ) + ] +) +""" + + OUTPUT_FILE.write_text(content, encoding="utf-8") + + print(f"Version_info erzeugt:") + print(f" Version: {textvers}") + print(f" Datei: {OUTPUT_FILE.resolve()}") + + +if __name__ == "__main__": + main()