§
    kÍâhÕ  ã                   óV   — d dl Z d dlZd dlmZ d dlmZ d dlmZ  G d„ de¦  «        ZdS )é    N)Úsettings)Ú	send_mail)ÚBaseCommandc                   ó<   ‡ — e Zd ZdZd„ Zˆ fd„Zˆ fd„Z	 d	d„Zˆ xZS )
ÚEmailNotificationCommanda   
    A BaseCommand subclass which adds sending email fuctionality.

    Subclasses will have an extra command line option ``--email-notification``
    and will be able to send emails by calling ``send_email_notification()``
    if SMTP host and port are specified in settings. The handling of the
    command line option is left to the management command implementation.
    Configuration is done in settings.EMAIL_NOTIFICATIONS dict.

    Configuration example::

        EMAIL_NOTIFICATIONS = {
            'scripts.my_script': {
                'subject': 'my_script subject',
                'body': 'my_script body',
                'from_email': 'from_email@example.com',
                'recipients': ('recipient0@example.com',),
                'no_admins': False,
                'no_traceback': False,
                'notification_level': 0,
                'fail_silently': False
            },
            'scripts.another_script': {
                ...
            },
            ...
        }

    Configuration explained:
        subject:            Email subject.
        body:               Email body.
        from_email:         Email from address.
        recipients:         Sequence of email recipient addresses.
        no_admins:          When True do not include ADMINS to recipients.
        no_traceback:       When True do not include traceback to email body.
        notification_level: 0: send email on fail, 1: send email always.
        fail_silently:      Parameter passed to django's send_mail().
    c                 ón   — |                      ddddd¬¦  «         |                      ddddd	¬¦  «         d S )
Nz--email-notificationsÚ
store_trueFÚemail_notificationsz%Send email notifications for command.)ÚactionÚdefaultÚdestÚhelpz--email-exceptionÚemail_exceptionz"Send email for command exceptions.)Úadd_argument)ÚselfÚparsers     úg/var/www/histauto/venv/lib/python3.11/site-packages/django_extensions/management/email_notifications.pyÚadd_argumentsz&EmailNotificationCommand.add_arguments2   sf   € Ø×ÒØ#ØØØ&Ø8ð 	ñ 	
ô 	
ð 	
ð 	×ÒØØØØ"Ø5ð 	ñ 	
ô 	
ð 	
ð 	
ð 	
ó    c                 ó~   •— d                      |¦  «        | _        t          ¦   «                              |¦  «         dS )z8Overriden in order to access the command line arguments.ú N)ÚjoinÚargv_stringÚsuperÚrun_from_argv)r   ÚargvÚ	__class__s     €r   r   z&EmailNotificationCommand.run_from_argvB   s3   ø€ àŸ8š8 D™>œ>ˆÔÝ‰Œ×Ò˜dÑ#Ô#Ð#Ð#Ð#r   c                 ó¸   •— 	  t          ¦   «         j        |i |¤Ž dS # t          $ r1 |d         st          | dd¦  «        r|                      d¬¦  «         ‚ w xY w)aJ  
        Overriden in order to send emails on unhandled exception.

        If an unhandled exception in ``def handle(self, *args, **options)``
        occurs and `--email-exception` is set or `self.email_exception` is
        set to True send an email to ADMINS with the traceback and then
        reraise the exception.
        r   FT)Úinclude_tracebackN)r   ÚexecuteÚ	ExceptionÚgetattrÚsend_email_notification)r   ÚargsÚoptionsr   s      €r   r    z EmailNotificationCommand.executeG   s‚   ø€ ð	Ø�E‰GŒGŒO˜TÐ- WÐ-Ð-Ð-Ð-Ð-øÝð 	ð 	ð 	ØÐ(Ô)ð E­W°TÐ;LÈeÑ-TÔ-Tð EØ×,Ò,¸tÐ,ÑDÔDÐDØð	øøøs	   ƒ ž;ANFé   c           
      ó  — |�4	 t           j                             |i ¦  «        }n# t          $ r i }Y nw xY wi }|s?|                     dd¦  «        s)t	          | j                             d¦  «        ¦  «         dS |                     dd¦  «        }| j                             d¦  «        d         }|                     d	d
|z  ¦  «        }|re|                     dd¦  «        sO	 t          j
        ¦   «         \  }}	}
d                     t          j        |
¦  «        ¦  «        }|d|z  z  }~
n# ~
w xY w|                     dt           j        ¦  «        }t          |                     dg ¦  «        ¦  «        }|                     dd¦  «        s|                     t           j        ¦  «         |s/|dk    r't	          | j                             d¦  «        ¦  «         dS t%          |||||                     dd¦  «        ¬¦  «         dS )zÒ
        Send email notifications.

        Reads settings from settings.EMAIL_NOTIFICATIONS dict, if available,
        using ``notification_id`` as a key or else provides reasonable
        defaults.
        NÚnotification_levelr   z%Exiting, not in 'notify always' mode.Úsubjectz%Django extensions email notification.ú.éÿÿÿÿÚbodyz$Reporting execution of command: '%s'Úno_tracebackFÚ z

Traceback:

%s
Ú
from_emailÚ
recipientsÚ	no_adminszNo email recipients available.Úfail_silentlyT)r2   )r   ÚEMAIL_NOTIFICATIONSÚgetÚAttributeErrorÚprintÚstyleÚERRORÚ
__module__ÚsplitÚsysÚexc_infor   Ú	tracebackÚ	format_tbÚDEFAULT_FROM_EMAILÚlistÚextendÚADMINSr   )r   Únotification_idr   Ú	verbosityÚemail_settingsr)   Úcommand_namer,   Úexc_typeÚ	exc_valueÚexc_tracebackÚtrbr/   r0   s                 r   r#   z0EmailNotificationCommand.send_email_notificationW   sD  € ð Ð&ð$Ý!)Ô!=×!AÒ!AÀ/ÐSUÑ!VÔ!V��øÝ!ð $ð $ð $Ø!#���ð$øøøð  ˆNð !ð 	¨×);Ò);Ð<PÐRSÑ)TÔ)Tð 	Ý�$”*×"Ò"Ð#JÑKÔKÑLÔLÐLØˆFð !×$Ò$ YÐ0WÑXÔXˆà”×,Ò,¨SÑ1Ô1°"Ô5ˆà×!Ò!ØÐ:¸\ÑIñ
ô 
ˆð
 ð 	" ^×%7Ò%7¸ÈÑ%NÔ%Nð 	"ð"Ý58´\±^´^Ñ2�˜) ]Ø—g’g�iÔ1°-Ñ@Ô@ÑAÔA�ØÐ0°3Ñ6Ñ6�à!�Mø�MÐ!Ð!Ð!Ð!ð $×'Ò'¨µhÔ6QÑRÔRˆ
õ ˜.×,Ò,¨\¸2Ñ>Ô>Ñ?Ô?ˆ
à×!Ò! +¨uÑ5Ô5ð 	/Ø×Ò�hœoÑ.Ô.Ð.àð 	Ø˜1Š}ˆ}Ý�d”j×&Ò&Ð'GÑHÔHÑIÔIÐIØˆFõ 	ØØØØØ(×,Ò,¨_¸dÑCÔCð	
ñ 	
ô 	
ð 	
ð 	
ð 	
s   „ % ¥4³4Ã"AD* Ä*D-)NFr&   )	Ú__name__r9   Ú__qualname__Ú__doc__r   r   r    r#   Ú__classcell__)r   s   @r   r   r   
   s†   ø€ € € € € ð%ð %ðN
ð 
ð 
ð $ð $ð $ð $ð $ð
ð ð ð ð ð" HIð?
ð ?
ð ?
ð ?
ð ?
ð ?
ð ?
ð ?
r   r   )	r;   r=   Údjango.confr   Údjango.core.mailr   Údjango.core.managementr   r   © r   r   ú<module>rS      sŽ   ðà 
€
€
€
Ø Ð Ð Ð à  Ð  Ð  Ð  Ð  Ð  Ø &Ð &Ð &Ð &Ð &Ð &Ø .Ð .Ð .Ð .Ð .Ð .ðL
ð L
ð L
ð L
ð L
˜{ñ L
ô L
ð L
ð L
ð L
r   