conf added

This commit is contained in:
hubobel 2025-12-24 09:59:27 +01:00
parent d91c277ada
commit 5d9a00772d
2 changed files with 45 additions and 2 deletions

View file

@ -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'])