.log Unterstützung
This commit is contained in:
parent
3478a0eb91
commit
6f0ff4bc00
1 changed files with 40 additions and 25 deletions
|
|
@ -13,6 +13,7 @@ from logging.handlers import RotatingFileHandler
|
||||||
|
|
||||||
|
|
||||||
def setup_logging(app_dir, level=logging.INFO, console=True):
|
def setup_logging(app_dir, level=logging.INFO, console=True):
|
||||||
|
logging.getLogger("httpx").setLevel(logging.WARNING)
|
||||||
log_file = app_dir / "Simbriefimport.log"
|
log_file = app_dir / "Simbriefimport.log"
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
@ -163,7 +164,8 @@ def ai(prompt):
|
||||||
def stimmung():
|
def stimmung():
|
||||||
tone = (passw['Prompt']['tone'])
|
tone = (passw['Prompt']['tone'])
|
||||||
tone = random.choice(list(tone))
|
tone = random.choice(list(tone))
|
||||||
print(tone)
|
|
||||||
|
#print(tone)
|
||||||
return tone
|
return tone
|
||||||
def WelcomePilot():
|
def WelcomePilot():
|
||||||
prompt_org = passw['Prompt']['CptPrompt']
|
prompt_org = passw['Prompt']['CptPrompt']
|
||||||
|
|
@ -295,8 +297,8 @@ def Simbriefimport():
|
||||||
zfw = data['weights']['est_zfw']
|
zfw = data['weights']['est_zfw']
|
||||||
airline_icao = general.get("icao_airline")
|
airline_icao = general.get("icao_airline")
|
||||||
route = data['general']['route']
|
route = data['general']['route']
|
||||||
print(data.keys())
|
#print(data.keys())
|
||||||
print(data['general']['route'])
|
#print(data['general']['route'])
|
||||||
return (zfw, tow, payload, pax, metar_dest, metar_origin, fuel, distance, fl, flightlevel, flightnumber, airline,
|
return (zfw, tow, payload, pax, metar_dest, metar_origin, fuel, distance, fl, flightlevel, flightnumber, airline,
|
||||||
aircraft_name, aircraft_icao, land_time, start_time, block, time, aircraft, dest_icao, dest_name, dest,
|
aircraft_name, aircraft_icao, land_time, start_time, block, time, aircraft, dest_icao, dest_name, dest,
|
||||||
origin_icao, origin_name, origin, general, airline_icao, route)
|
origin_icao, origin_name, origin, general, airline_icao, route)
|
||||||
|
|
@ -321,7 +323,8 @@ def BACKUP(Pfad):
|
||||||
|
|
||||||
# Prüfen, ob BACKUP bereits existiert
|
# Prüfen, ob BACKUP bereits existiert
|
||||||
if backup_dir.exists():
|
if backup_dir.exists():
|
||||||
print("BACKUP existiert bereits – keine Dateien wurden kopiert.")
|
logging.info("BACKUP existiert bereits – keine Dateien wurden kopiert.")
|
||||||
|
#print("BACKUP existiert bereits – keine Dateien wurden kopiert.")
|
||||||
else:
|
else:
|
||||||
# BACKUP anlegen
|
# BACKUP anlegen
|
||||||
backup_dir.mkdir(parents=True)
|
backup_dir.mkdir(parents=True)
|
||||||
|
|
@ -334,7 +337,10 @@ def BACKUP(Pfad):
|
||||||
shutil.copy2(src, dst)
|
shutil.copy2(src, dst)
|
||||||
print(f"Kopiert: {src.name}")
|
print(f"Kopiert: {src.name}")
|
||||||
|
|
||||||
print(f"Backup erstellt. {len(txt_files)} Datei(en) gesichert.")
|
logging.info(
|
||||||
|
"Backup erstellt. %d Datei(en) gesichert.",
|
||||||
|
len(txt_files)
|
||||||
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -350,12 +356,20 @@ setup_logging(app_dir, level=logging.INFO, console=True)
|
||||||
conf_file = app_dir / "Simbriefimport.conf"
|
conf_file = app_dir / "Simbriefimport.conf"
|
||||||
|
|
||||||
if conf_file.exists():
|
if conf_file.exists():
|
||||||
print("Konfigurationsdatei gefunden:", conf_file)
|
#print("Konfigurationsdatei gefunden:", conf_file)
|
||||||
|
logging.info(
|
||||||
|
"Konfigurationsdatei gefunden: %s",
|
||||||
|
conf_file
|
||||||
|
)
|
||||||
with open(conf_file) as file:
|
with open(conf_file) as file:
|
||||||
passw = json.load(file)
|
passw = json.load(file)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("Keine Konfigurationsdatei vorhanden:", conf_file)
|
#print("Keine Konfigurationsdatei vorhanden:", conf_file)
|
||||||
|
logging.info(
|
||||||
|
"keine Konfigurationsdatei gefunden: %s",
|
||||||
|
conf_file
|
||||||
|
)
|
||||||
|
|
||||||
#passw = conf()
|
#passw = conf()
|
||||||
client = OpenAI(
|
client = OpenAI(
|
||||||
|
|
@ -369,32 +383,33 @@ Stimmung = str(stimmung())
|
||||||
(zfw, tow, payload, pax, metar_dest, metar_origin, fuel, distance, fl, flightlevel, flightnumber, airline,
|
(zfw, tow, payload, pax, metar_dest, metar_origin, fuel, distance, fl, flightlevel, flightnumber, airline,
|
||||||
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, route) = Simbriefimport()
|
origin_name, origin, general, airline_icao, route) = Simbriefimport()
|
||||||
|
logging.info("Stimmung: %s", Stimmung)
|
||||||
logging.info("--------------------------------------------------")
|
logging.info("--------------------------------------------------")
|
||||||
logging.info("FLUGINFORMATIONEN")
|
logging.info("FLUGINFORMATIONEN")
|
||||||
logging.info("--------------------------------------------------")
|
logging.info("--------------------------------------------------")
|
||||||
logging.info("Airline (ICAO): %s", general.get("icao_airline"))
|
logging.info("Airline (ICAO): %s", general.get("icao_airline"))
|
||||||
logging.info("Airlinename: %s", airline)
|
logging.info("Airlinename: %s", airline)
|
||||||
logging.info("Flugnummer: %s", general.get("flight_number"))
|
logging.info("Flugnummer: %s", general.get("flight_number"))
|
||||||
|
|
||||||
logging.info("Abflug ICAO: %s", origin.get("icao_code"))
|
logging.info("Abflug ICAO: %s", origin.get("icao_code"))
|
||||||
logging.info("Abflugort: %s", origin_name)
|
logging.info("Abflugort: %s", origin_name)
|
||||||
|
|
||||||
logging.info("Ziel ICAO: %s", dest.get("icao_code"))
|
logging.info("Ziel ICAO: %s", dest.get("icao_code"))
|
||||||
logging.info("Zielort: %s", dest_name)
|
logging.info("Zielort: %s", dest_name)
|
||||||
|
logging.info("Route: %s", route)
|
||||||
|
|
||||||
logging.info("Geplante Blockzeit: %s", block)
|
logging.info("Geplante Blockzeit: %s", block)
|
||||||
logging.info("Geplanter Start: %s UTC", start_time)
|
logging.info("Geplanter Start: %s UTC", start_time)
|
||||||
logging.info("Geplante Landung: %s UTC", land_time)
|
logging.info("Geplante Landung: %s UTC", land_time)
|
||||||
|
|
||||||
logging.info("Fluggerät: %s (%s)", aircraft_icao, aircraft_name)
|
logging.info("Fluggerät: %s (%s)", aircraft_icao, aircraft_name)
|
||||||
logging.info("Cruiselevel: FL%s", fl)
|
logging.info("Cruiselevel: FL%s", fl)
|
||||||
logging.info("Entfernung: %s nm", distance)
|
logging.info("Entfernung: %s nm", distance)
|
||||||
|
|
||||||
logging.info("Fuel: %s kg", fuel)
|
logging.info("Fuel: %s kg", fuel)
|
||||||
logging.info("Passagiere: %s", pax)
|
logging.info("Passagiere: %s", pax)
|
||||||
logging.info("ZFW: %s kg", zfw)
|
logging.info("ZFW: %s kg", zfw)
|
||||||
logging.info("TOW: %s kg", tow)
|
logging.info("TOW: %s kg", tow)
|
||||||
|
|
||||||
logging.info(
|
logging.info(
|
||||||
"Wetter Abflug %s: %s",
|
"Wetter Abflug %s: %s",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue