Pfade angepasst
This commit is contained in:
parent
52dd0eb5a7
commit
03ed438be6
1 changed files with 42 additions and 19 deletions
|
|
@ -6,6 +6,7 @@ from openai import OpenAI
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import random
|
import random
|
||||||
|
import shutil
|
||||||
|
|
||||||
def conf():
|
def conf():
|
||||||
appname = os.path.basename(sys.argv[0])
|
appname = os.path.basename(sys.argv[0])
|
||||||
|
|
@ -122,7 +123,7 @@ def METAR():
|
||||||
return antwort_AI
|
return antwort_AI
|
||||||
def replaceFiles():
|
def replaceFiles():
|
||||||
files = []
|
files = []
|
||||||
for datei in Path(Pfad).glob("*.txt"):
|
for datei in Path(Pfad_wd).glob("*.txt"):
|
||||||
with open(datei, "r", encoding="utf-8") as f:
|
with open(datei, "r", encoding="utf-8") as f:
|
||||||
files.append(f"{datei.name}")
|
files.append(f"{datei.name}")
|
||||||
inhalt = f.read()
|
inhalt = f.read()
|
||||||
|
|
@ -174,20 +175,42 @@ def Simbriefimport():
|
||||||
def txtSave(Datei, Inhalt):
|
def txtSave(Datei, Inhalt):
|
||||||
voice = None
|
voice = None
|
||||||
Inhalt = Inhalt.replace("„", "").replace("“", "").replace('"', "")
|
Inhalt = Inhalt.replace("„", "").replace("“", "").replace('"', "")
|
||||||
|
try:
|
||||||
|
|
||||||
with open(Datei, "r", encoding="utf-8") as f:
|
with open(Datei, "r", encoding="utf-8") as f:
|
||||||
erste_zeile = f.readline().strip()
|
erste_zeile = f.readline().strip()
|
||||||
if erste_zeile.startswith("##Voice:"):
|
if erste_zeile.startswith("##Voice:"):
|
||||||
voice = erste_zeile + "\n"
|
voice = erste_zeile + "\n"
|
||||||
Inhalt = voice + Inhalt
|
Inhalt = voice + Inhalt
|
||||||
|
except:
|
||||||
|
None
|
||||||
with open(Datei, 'w', encoding="utf-8") as e:
|
with open(Datei, 'w', encoding="utf-8") as e:
|
||||||
e.write(Inhalt)
|
e.write(Inhalt)
|
||||||
return None
|
return None
|
||||||
|
def BACKUP(Pfad):
|
||||||
|
ryr_dir = Path(Pfad)
|
||||||
|
backup_dir = ryr_dir / "BACKUP"
|
||||||
|
|
||||||
|
# Prüfen, ob BACKUP bereits existiert
|
||||||
|
if backup_dir.exists():
|
||||||
|
print("BACKUP existiert bereits – keine Dateien wurden kopiert.")
|
||||||
|
else:
|
||||||
|
# BACKUP anlegen
|
||||||
|
backup_dir.mkdir(parents=True)
|
||||||
|
|
||||||
|
# Alle .txt Dateien kopieren
|
||||||
|
txt_files = list(ryr_dir.glob("*.txt"))
|
||||||
|
|
||||||
|
for src in txt_files:
|
||||||
|
dst = backup_dir / src.name
|
||||||
|
shutil.copy2(src, dst)
|
||||||
|
print(f"Kopiert: {src.name}")
|
||||||
|
|
||||||
|
print(f"Backup erstellt. {len(txt_files)} Datei(en) gesichert.")
|
||||||
|
return None
|
||||||
|
|
||||||
host = os.getcwd()
|
host = os.getcwd()
|
||||||
|
Pfad = os.getcwd() + '/Announcements/'
|
||||||
Pfad = os.getcwd() + '/Universal_txts/Windows'
|
|
||||||
|
|
||||||
ordnerneu = Path(Pfad + '/neu/')
|
|
||||||
ordnerneu.mkdir(exist_ok=True)
|
|
||||||
|
|
||||||
passw = conf()
|
passw = conf()
|
||||||
client = OpenAI(
|
client = OpenAI(
|
||||||
|
|
@ -202,10 +225,6 @@ client = OpenAI(
|
||||||
aircraft_name, aircraft_icao, land_time, start_time, block, time, aircraft, dest_icao, dest_name, dest, origin_icao,
|
aircraft_name, aircraft_icao, land_time, start_time, block, time, aircraft, dest_icao, dest_name, dest, origin_icao,
|
||||||
origin_name, origin, general, airline_icao) = Simbriefimport()
|
origin_name, origin, general, airline_icao) = Simbriefimport()
|
||||||
|
|
||||||
print(os.getcwd() + '/Universal_txts/Windows/' + airline_icao)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print('')
|
print('')
|
||||||
print("Airline:", general.get("icao_airline"))
|
print("Airline:", general.get("icao_airline"))
|
||||||
print("Airlinename:", airline)
|
print("Airlinename:", airline)
|
||||||
|
|
@ -227,11 +246,15 @@ print("TOW:", tow, 'kg')
|
||||||
print("Wetter:", origin.get("icao_code"), metar_origin)
|
print("Wetter:", origin.get("icao_code"), metar_origin)
|
||||||
print("Wetter:", dest["icao_code"], metar_dest)
|
print("Wetter:", dest["icao_code"], metar_dest)
|
||||||
|
|
||||||
|
Pfad_wd = Pfad + airline_icao + '/'
|
||||||
|
|
||||||
|
ordnerneu = Path(Pfad_wd + '/neu/')
|
||||||
|
print(Pfad_wd)
|
||||||
|
BACKUP(Pfad_wd)
|
||||||
print(replaceFiles())
|
print(replaceFiles())
|
||||||
|
|
||||||
|
ordnerneu.mkdir(exist_ok=True)
|
||||||
|
|
||||||
metarCabin = METAR()
|
metarCabin = METAR()
|
||||||
print(metarCabin.choices[0].message.content)
|
print(metarCabin.choices[0].message.content)
|
||||||
metar = metarCabin.choices[0].message.content
|
metar = metarCabin.choices[0].message.content
|
||||||
|
|
@ -244,8 +267,8 @@ Inhalt = "\n".join(filter(None, map(str.strip, Inhalt.splitlines())))
|
||||||
print(Inhalt)
|
print(Inhalt)
|
||||||
print(os.getcwd())
|
print(os.getcwd())
|
||||||
|
|
||||||
Pfad = os.getcwd() + '/Universal_txts/Windows/neu/BoardingWelcomePilot.txt'
|
Pfad = Pfad_wd + 'BoardingWelcomePilot.txt'
|
||||||
txtSave(Pfad, Inhalt)
|
txtSave(Pfad, Inhalt)
|
||||||
|
|
||||||
Pfad = os.getcwd() + '/Universal_txts/Windows/neu/FastenSeatbelt.txt'
|
Pfad = Pfad_wd + 'FastenSeatbelt.txt'
|
||||||
txtSave(Pfad, metar)
|
txtSave(Pfad, metar)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue