From 5d9a00772de3bbf21ebacc0304d1eb9f9f9a9546 Mon Sep 17 00:00:00 2001 From: hubobel Date: Wed, 24 Dec 2025 09:59:27 +0100 Subject: [PATCH] conf added --- Simbriefimport.example | 10 ++++++++++ Simbriefimport.py | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 Simbriefimport.example diff --git a/Simbriefimport.example b/Simbriefimport.example new file mode 100644 index 0000000..a9ddc15 --- /dev/null +++ b/Simbriefimport.example @@ -0,0 +1,10 @@ +{ + "AI": { + "Model": "gpt-4.1-mini", + "Token": "SECRET TOKE" + }, + "Prompt": { + "CptPrompt": "Du bist der Pilot auf einem Linienflug und begrüßt deine Fluggäste am Startflughafen.", + "PurserPrompt": "Du bist Purser auf einem Flug an das in der METAR genannte Ziel.Der Flug ist noch nicht vollendet! Informiere die Fluggäste im Zuge der bevorstehenden Landung über die aktuelle Wetterlage hinsichtlich Temperatur, Wind und Sonne. Verhalte dich dabei wie die Wetterfee aus den Nachrichten und beschränke die Antwort auf maximal 2 kurze Sätze. Die Windrichtung bitte ignorieren. Nenne dabei den Zielflughafen mit Namen. Vermeide Aussagen wie 'Willkommen'. Sei dabei freundlich und kundenorientiert." + } +} \ No newline at end of file diff --git a/Simbriefimport.py b/Simbriefimport.py index 5b468f3..9a5b8b4 100644 --- a/Simbriefimport.py +++ b/Simbriefimport.py @@ -2,9 +2,10 @@ import requests import json from pathlib import Path from datetime import datetime, timezone +from openai import OpenAI +import os +import sys -from aiohttp import payload_type -from proto import Field USERNAME = "hubobel" URL = "https://www.simbrief.com/api/xml.fetcher.php" @@ -16,7 +17,36 @@ Pfad = 'Universal_txts/Windows' ordnerneu = Path(Pfad + '/neu/') ordnerneu.mkdir(exist_ok=True) +def conf(): + appname = os.path.basename(sys.argv[0]) + appname = appname.replace(".py", ".conf") + absFilePath = os.path.abspath(__file__) + absFilePath = absFilePath.replace(".py", ".conf") + if os.path.isfile(absFilePath) is False: + print(appname + ' scheint es nicht zu geben.') + print('Ich lege eine neue Datei ' + appname + ' an.') + passw = {'Prompt': + { + "PurserPrompt": "", + "CptPrompt": "" + + }, + 'AI': + { + "Token": "", + "Model": "" + } + } + + print(str(appname) + ' bitte entsprechend befüllen.') + with open(absFilePath, 'w') as fp: + json.dump(passw, fp, sort_keys=True, indent=4) + quit() + else: + with open(absFilePath) as file: + passw = json.load(file) + return passw def minuten_zu_zeit(minuten) -> str: minuten = int(minuten) stunden = minuten // 60 # volle Stunden @@ -62,6 +92,7 @@ def unix_to_datetime(timestamp: int) -> str: return datetime.fromtimestamp(timestamp, tz=timezone.utc).strftime("%d.%m.%Y %H:%M:%S") + resp = requests.get(URL, params=params, timeout=15) resp.raise_for_status() data = resp.json() # dict @@ -126,3 +157,5 @@ for datei in Path(Pfad).glob("*.txt"): with open(dateineu,'w', encoding="utf-8") as e: e.write(inhalt_neu) +passw = conf() +print(passw['AI']['Token']) \ No newline at end of file