s'iSrSSKrSSKJr SSKJr SSKJr SSKJr SSK J r SSK J r S r "S S 5rg!\a \R"S 5 S r N'f=f)zf Notification Manager for Python Scheduler Handles popup notifications and future email notifications N)datetime)Optional)logger)SchedulerDatabase)SchedulerConfig) ToastNotifierTz6win10toast not available, popup notifications disabledFc \rSrSrSrS\S\4SjrSS\S\ S \ S \ \ S \ \4 S jjr S\ S \ S \ \ S \ \S \ 4 SjrS\S\ S\ S\ \ 4SjrS\ S\ 4SjrSrSrg)NotificationManagerz(Manages notifications for job executionsdbconfigcXlX l[(a [5OSUlUR =(a [Ul[R"SUR S35 g)Nz*NotificationManager initialized (enabled: )) r r TOAST_AVAILABLErtoasterenable_popup_notificationsenabledrinfo)selfr r s 2c:\PYTHON\Scheduler\daemon\notification_manager.py__init__NotificationManager.__init__sG *9/}t 88L_  @aPQN execution_idjob_namestatusduration exit_codecUR(dgSnUS:Xa#URRS5(aSnOQUS:Xa#URRS5(aSnO(US:Xa"URRS 5(aSnU(dgURX#XE5upxn [R "UR XX4SS 9n U R5 g) z Send notification for job execution result Args: execution_id: Execution ID job_name: Job name status: Execution status ('completed', 'failed', 'timeout', etc.) duration: Duration in seconds exit_code: Process exit code NF completedz"notifications.notify_on_completionTfailedznotifications.notify_on_failuretimeoutznotifications.notify_on_timeout)targetargsdaemon)rr get_build_notification_content threadingThread_send_toast_notificationstart) rrrrrr should_notifytitlemessage icon_paththreads rnotify_job_result%NotificationManager.notify_job_result s||  [ T[[__5Y%Z%Z M x DKKOO4U$V$V M y T[[__5V%W%W M %)$D$D h% ! !!00w:   rreturncUS:XaSU3nU(aSUSS3nOSnSnO6US:XaS U3nUbS US 3nOS nSnOUS :Xa SU3nSnSnO SU3nSU3nSnXVU4$)z$Build notification title and messager zJob Completed - zCompleted successfully in z.1fszCompleted successfullyNr!z Job Failed - zFailed with exit code z. Check logs for details.zFailed. Check logs for details.r"zJob Timeout - z3Job exceeded timeout limit. Process was terminated.z Job Status - zStatus: )rrrrrr-r.r/s rr'/NotificationManager._build_notification_contentIs [ &xj1E6xnAF2I x #H:.E$29+=VW;I y $XJ/EKGI$H:.E )GIy((rr-r.r/c UR(dgURRSS5nURRUUUUSS9 URR USSUSU3[ R"5S 9 [R"S U35 g![aZn[R"S U35 URR USS USU3[U5S 9 SnAg! SnAg=fSnAff=f)z Send Windows toast notification Args: execution_id: Execution ID for logging title: Notification title message: Notification message icon_path: Optional icon path N$notifications.popup_duration_seconds T)r-msgr/rthreadedpopupsentz: )rnotification_typerr.sent_atz&Sent popup notification for execution z#Failed to send popup notification: r!)rr?rr.error) rr r& show_toastr create_notificationrnowrr ExceptionrAstr)rrr-r.r/res rr*,NotificationManager._send_toast_notificationjs|| $ {{'MrRH LL # ##! $  GG ' ')") 'G9-  (  KK@O P  LL>qcB C ++!-&-#$gRy1a& ,  s0BB D&C;+C00C82C;8C;;DcUR(aUR(d[R"SU35 gURR SS5nURR UUUSS9 [R"SU35 g![a#n[R"SU35 SnAgSnAff=f) z Send a custom notification (not tied to a job execution) Args: title: Notification title message: Notification message z)Custom notification not sent (disabled): Nr9r:T)r-r;rr<zSent custom notification: z$Failed to send custom notification: ) rrrdebugr r&rBrrErA)rr-r.rrGs rsend_custom_notification,NotificationManager.send_custom_notifications||4<< LLDUGL M  E{{'MrRH LL # #! $  KK4UG< = E LL?sC D D EsAB B=B88B=c$URSSS9 g)zSend a test notificationz$Python Scheduler - Test NotificationzMThis is a test notification from Python Scheduler. Notifications are working!)r-r.N)rK)rs rtest_notification%NotificationManager.test_notifications %%8c & r)r r rr)NN)__name__ __module__ __qualname____firstlineno____doc__rrrintrFrfloatr1tupler'r*rKrN__static_attributes__r6rrr r s2R,RoRW['c'S'#'#+E?'FNsm'R)C)).6uo)/7})AF)B2S22*-2:B3-2hEcECE6 rr )rTr(rtypingrlogurur core.databaser core.configr win10toastrr ImportErrorwarningr r6rrr`sZ +'(O h h  NNKLOs9AA