diff --git a/bitbylaw/steps/advoware_cal_sync/advoware_calendar_sync_step.py b/bitbylaw/steps/advoware_cal_sync/advoware_calendar_sync_step.py index 2e163722..efdf6895 100644 --- a/bitbylaw/steps/advoware_cal_sync/advoware_calendar_sync_step.py +++ b/bitbylaw/steps/advoware_cal_sync/advoware_calendar_sync_step.py @@ -38,7 +38,7 @@ async def get_google_service(context): else: # Hier würde normalerweise der OAuth Flow laufen # Für Server-Umgebung brauchen wir Service Account oder gespeicherte Credentials - context.logger.warning("Google OAuth Credentials nicht gefunden. Bitte token.pickle bereitstellen oder Google Calendar Sync überspringen.") + print("WARNING: Google OAuth Credentials nicht gefunden. Bitte token.pickle bereitstellen oder Google Calendar Sync überspringen.") return None # Token speichern @@ -53,10 +53,10 @@ async def get_advoware_employees(context): try: # Annahme: Mitarbeiter-Endpoint existiert ähnlich wie andere result = await advoware.api_call('Mitarbeiter') - context.logger.info(f"Advoware Mitarbeiter abgerufen: {len(result) if isinstance(result, list) else 'unbekannt'}") + print(f"Advoware Mitarbeiter abgerufen: {len(result) if isinstance(result, list) else 'unbekannt'}") return result if isinstance(result, list) else [] except Exception as e: - context.logger.error(f"Fehler beim Abrufen der Mitarbeiter: {e}") + print(f"Fehler beim Abrufen der Mitarbeiter: {e}") return [] async def ensure_google_calendar(service, employee_kuerzel, context): @@ -68,7 +68,7 @@ async def ensure_google_calendar(service, employee_kuerzel, context): calendar_list = service.calendarList().list().execute() for calendar in calendar_list.get('items', []): if calendar['summary'] == calendar_name: - context.logger.info(f"Google Calendar '{calendar_name}' existiert bereits") + print(f"Google Calendar '{calendar_name}' existiert bereits") return calendar['id'] # Neuen Kalender erstellen @@ -80,12 +80,12 @@ async def ensure_google_calendar(service, employee_kuerzel, context): created_calendar = service.calendars().insert(body=calendar_body).execute() calendar_id = created_calendar['id'] - context.logger.info(f"Google Calendar '{calendar_name}' erstellt mit ID: {calendar_id}") + print(f"Google Calendar '{calendar_name}' erstellt mit ID: {calendar_id}") return calendar_id except Exception as e: - context.logger.error(f"Fehler bei Google Calendar für {employee_kuerzel}: {e}") + print(f"Fehler bei Google Calendar für {employee_kuerzel}: {e}") return None async def get_advoware_appointments(employee_kuerzel, context): @@ -104,10 +104,10 @@ async def get_advoware_appointments(employee_kuerzel, context): } result = await advoware.api_call('Termine', method='GET', params=params) appointments = result if isinstance(result, list) else [] - context.logger.info(f"Advoware Termine für {employee_kuerzel}: {len(appointments)} gefunden") + print(f"Advoware Termine für {employee_kuerzel}: {len(appointments)} gefunden") return appointments except Exception as e: - context.logger.error(f"Fehler beim Abrufen der Termine für {employee_kuerzel}: {e}") + print(f"Fehler beim Abrufen der Termine für {employee_kuerzel}: {e}") return [] async def get_google_events(service, calendar_id, context): @@ -126,10 +126,10 @@ async def get_google_events(service, calendar_id, context): ).execute() events = events_result.get('items', []) - context.logger.info(f"Google Calendar Events: {len(events)} gefunden") + print(f"Google Calendar Events: {len(events)} gefunden") return events except Exception as e: - context.logger.error(f"Fehler beim Abrufen der Google Events: {e}") + print(f"Fehler beim Abrufen der Google Events: {e}") return [] async def sync_appointment_to_google(service, calendar_id, appointment, full_content, context): @@ -172,11 +172,11 @@ async def sync_appointment_to_google(service, calendar_id, appointment, full_con # Event erstellen created_event = service.events().insert(calendarId=calendar_id, body=event_body).execute() - context.logger.info(f"Termin {appointment.get('frNr')} zu Google Calendar hinzugefügt") + print(f"Termin {appointment.get('frNr')} zu Google Calendar hinzugefügt") return created_event except Exception as e: - context.logger.error(f"Fehler beim Sync zu Google für Termin {appointment.get('frNr')}: {e}") + print(f"Fehler beim Sync zu Google für Termin {appointment.get('frNr')}: {e}") return None async def sync_event_to_advoware(service, calendar_id, event, employee_kuerzel, context): @@ -220,11 +220,11 @@ async def sync_event_to_advoware(service, calendar_id, event, employee_kuerzel, event['extendedProperties']['private']['advoware_frnr'] = str(new_frnr) service.events().update(calendarId=calendar_id, eventId=event['id'], body=event).execute() - context.logger.info(f"Neuer Advoware Termin erstellt: {new_frnr}, frNr in Google aktualisiert") + print(f"Neuer Advoware Termin erstellt: {new_frnr}, frNr in Google aktualisiert") return new_frnr except Exception as e: - context.logger.error(f"Fehler beim Sync zu Advoware für Google Event {event.get('id')}: {e}") + print(f"Fehler beim Sync zu Advoware für Google Event {event.get('id')}: {e}") return None async def handler(req, context): @@ -233,12 +233,12 @@ async def handler(req, context): body = req.get('body', {}) full_content = body.get('full_content', True) # Default: volle Termindetails - context.logger.info(f"Starte Advoware Calendar Sync, full_content: {full_content}") + print(f"Starte Advoware Calendar Sync, full_content: {full_content}") # Google Calendar Service initialisieren service = await get_google_service(context) if not service: - context.logger.warning("Google Calendar Service nicht verfügbar. Sync wird übersprungen.") + print("Google Calendar Service nicht verfügbar. Sync wird übersprungen.") return { 'status': 200, 'body': { @@ -259,10 +259,10 @@ async def handler(req, context): for employee in employees: kuerzel = employee.get('kuerzel') or employee.get('anwalt') if not kuerzel: - context.logger.warning(f"Mitarbeiter ohne Kürzel übersprungen: {employee}") + print(f"Mitarbeiter ohne Kürzel übersprungen: {employee}") continue - context.logger.info(f"Verarbeite Mitarbeiter: {kuerzel}") + print(f"Verarbeite Mitarbeiter: {kuerzel}") # Google Calendar sicherstellen calendar_id = await ensure_google_calendar(service, kuerzel, context) @@ -286,7 +286,7 @@ async def handler(req, context): for event in google_events: await sync_event_to_advoware(service, calendar_id, event, kuerzel, context) - context.logger.info(f"Advoware Calendar Sync abgeschlossen. {total_synced} Termine synchronisiert.") + print(f"Advoware Calendar Sync abgeschlossen. {total_synced} Termine synchronisiert.") return { 'status': 200, @@ -298,7 +298,7 @@ async def handler(req, context): } except Exception as e: - context.logger.error(f"Fehler beim Advoware Calendar Sync: {e}") + print(f"Fehler beim Advoware Calendar Sync: {e}") return { 'status': 500, 'body': {