ó
Qü½cc           @   s  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l m	 Z	 d d l m
 Z
 d d l m Z d d l m Z d d l m Z d d	 l m Z d d
 l m Z d Z y e e f Wn e k
 rd Z d Z n Xd e e f d „  ƒ  YZ d S(   s   Outgoing queue runner.iÿÿÿÿN(   t   mm_cfg(   t   Message(   t   Errors(   t   LockFile(   t   Runner(   t   Switchboard(   t   BounceMixin(   t   syslogi
   i   i    t   OutgoingRunnerc           B   s;   e  Z e j Z d d  d „ Z d „  Z e j	 Z	 d „  Z
 RS(   i   c         C   sq   t  j |  | | ƒ t j |  ƒ d t j } t | ƒ } t t j | d ƒ |  _	 t
 |  _ t t j ƒ |  _ d  S(   Ns   Mailman.Handlers.t   process(   R   t   __init__R   R    t   DELIVERY_MODULEt
   __import__t   getattrt   syst   modulest   _funct   Falset   _OutgoingRunner__loggedR   t   RETRYQUEUE_DIRt   _OutgoingRunner__retryq(   t   selft   slicet	   numslicest   modnamet   mod(    (    s;   /export/web/mailman/mailman/Mailman/Queue/OutgoingRunner.pyR
   4   s    	c         C   s3  | j  d d ƒ } t j ƒ  | k  r( t S| j ƒ  y^ t j ƒ  } |  j | | | ƒ | t j ƒ  k r† t d d t ƒ t j	 d ƒ n  t
 |  _ Wnœt j k
 rý t j } | d k rÁ d } n  |  j sì t d d t j | ƒ t |  _ n  |  j d ƒ t St j k
 r.} | j  d ƒ r>| j r>|  j | | d ƒ q/| j rf|  j | j ƒ  | j | ƒ n  | j r/t j ƒ  } | j }	 | j  d	 d ƒ }
 | j  d
 | ƒ } t |	 ƒ |
 k rÍ| | k rÚt
 Sn | t j } | t j } | | d <t |	 ƒ | d	 <| | d
 <|	 | d <|  j j | | ƒ q/n Xt
 S(   Nt   deliver_afteri    t   errors   child process leaked thru: %si   t   smtps+   Cannot connect to SMTP server %s on port %st   probe_tokent   last_recip_countt   deliver_untilt   recips(   t   gett   timet   Truet   Loadt   ost   getpidR   R   R   t   _exitR   R   t   socketR   R    t   SMTPPORTt   SMTPHOSTt   _snoozeR   t   SomeRecipientsFailedt   permfailurest   _probe_bouncet   _queue_bouncest   internal_namet   tempfailurest   lent   DELIVERY_RETRY_PERIODt   DELIVERY_RETRY_WAITR   t   enqueue(   R   t   mlistt   msgt   msgdataR   t   pidt   portt   et   nowR    R   R   (    (    s;   /export/web/mailman/mailman/Mailman/Queue/OutgoingRunner.pyt   _disposeA   sV    
					
		


c         C   s   t  j |  ƒ t j |  ƒ d  S(   N(   R   t   _cleanupR   (   R   (    (    s;   /export/web/mailman/mailman/Mailman/Queue/OutgoingRunner.pyR>   Œ   s    N(   t   __name__t
   __module__R    t   OUTQUEUE_DIRt   QDIRt   NoneR
   R=   R   t   _doperiodicR>   (    (    (    s;   /export/web/mailman/mailman/Mailman/Queue/OutgoingRunner.pyR   1   s
   		I	(   t   __doc__R%   R   t   copyR"   R(   t   emailt   MailmanR    R   R   R   t   Mailman.Queue.RunnerR   t   Mailman.Queue.SwitchboardR   t   Mailman.Queue.BounceRunnerR   t   Mailman.Logging.SyslogR   t   DEAL_WITH_PERMFAILURES_EVERYR#   R   t	   NameErrorR   (    (    (    s;   /export/web/mailman/mailman/Mailman/Queue/OutgoingRunner.pyt   <module>   s*   
