7ec@sdZddlZddlZddlZddlZddlZdZdejfdYZdd#d d$d d ddddddddgZ xe e e D]Z e e Z ee edkreje ejZ nBgZx*e D]"Z ejeje ejqWeeZ [e e e <[ qW[ ddejdejejdejdejgZejdejejBZdZegZdZdZd Zed!ksejd"ekrendS(%s6mailerdaemon - classes to parse mailer-daemon messagesiNsmailerdaemon.Unparseablet ErrorMessagecBs#eZdZdZdZRS(cCs tjj||d|_dS(Nt(trfc822tMessaget__init__tsub(tselftfp((s2/usr/lib64/python2.7/Tools/scripts/mailerdaemon.pyR scCsU|jd}|sdS|j}|jdr8dSd|krHdS||_dS(NtSubjectis waiting mailitwarning(t getheadertlowert startswithR(RR((s2/usr/lib64/python2.7/Tools/scripts/mailerdaemon.pyt is_warnings   cCsPxCtD];}|jy||j|jSWqtk rAqXqWtdS(N(t EMPARSERSt rewindbodyRRt Unparseable(Rtp((s2/usr/lib64/python2.7/Tools/scripts/mailerdaemon.pyt get_errorss   (t__name__t __module__RR R(((s2/usr/lib64/python2.7/Tools/scripts/mailerdaemon.pyR s  s.error: (?Punresolvable): (?P.+)s?----- The following addresses had permanent fatal errors ----- s(?P[^ ].*) ( .* )?s(remote execution.* .*rmail (?P.+)s8The following recipients did not receive your message: sK +(?P.*) (The following recipients did not receive your message: )?s?------- Failure Reasons -------- (?P.*) (?P.*)s ^<(?P.*)>: (?P.*)s=^(?PUser mailbox exceeds allowed size): (?P.+)s0^5\d{2} <(?P[^ >]+)>\.\.\. (?P.+)s)^Original-Recipient: rfc822;(?P.*)sR^did not reach the following recipient\(s\): (?P.*) on .* +(?P.*)s+^ <(?P[^ >]+)> \.\.\. (?P.*)s@^Report on your message to: (?P.*) Reason: (?P.*)s^^Your message was not delivered to +(?P.*) +for the following reason: +(?P.*)sO^ was not +(?P[^ ].*?) * .* .* .* because:.* +(?P[^ ].*?) * Rs^5\d{2} <>\.\.\. (?P.*)s<>\.\.\. (?P.*)s^<<< 5\d{2} (?P.*)s,===== stderr was ===== rmail: (?P.*)s ^Diagnostic-Code: (?P.*)s^From:c Cs|j}tj|}|dkr6t|}n|jd}g}g}d}x*tD]"}t|td kr|dj|d|}|dk ry|jd}Wnt k rnXxL|dj ||j d|}|dkrPn|j |jdqWPqq^|j|d|}|dk r^|j |jdy|jd}Wnt k r{nXPq^q^W|st n|s|}|d dkr|d}nxtD] }t|tdkrxtt|dddD]} || } tjtj| j|jd tj} | j|}|dk r|j d j| jd |jdj|| =qqWqn|j|}|dk r|jd}PqqWnx8|D]0} |j d j| jd |jqW|S( Nitreasonitemailisreturned mail: Ris<>t s: ((treadtemparse_list_fromtsearchtNonetlentstarttemparse_list_listttypetgroupt IndexErrortmatchtendtappendRtemparse_list_reasontrangetretcompiletescapetjointsplitt MULTILINEtstrip( RRtdatatrest from_indexterrorstemailsRtregexptiRtexp((s2/usr/lib64/python2.7/Tools/scripts/mailerdaemon.pyt emparse_list\sj     "      # 0 3   .cCs@t|}t|}||kr(dS||kr8dSdSdS(Niii(tint(tatb((s2/usr/lib64/python2.7/Tools/scripts/mailerdaemon.pyt sort_numerics    cCstj|tjd}i}i}i}d}}}t|dtjd} | jtx| D]} t| } t | } | j d} d| | dfG| j r| j dGH|d}|rntj | d | qnqnny| j}Wn-tk r4d GH|d}| j qnnXt|Gd GHx|D]}y7| jd dd!\}}dtj||f}Wn d}nX|j|sd||Rt.tFroms %s %-40s is warning onlyt,s** Not parseableR1tdateis%s %02ds??????s%s (%s)s--------------s files parsed,sfiles warning-only,sfiles unparseables %d %s - %s %si(tostchdirR'R(tfiltertlistdirtsortR:topenRtgetaddrR tclosetrenameRRRtgetdatetcalendart month_abbrthas_keytkeysR$(tdirtmodifyR<t errordictt errorfirstt errorlasttnoktnwarntnbadtfilesR;RtmtsenderR1tetmmtddRAtlisttnumtfirsttlast((s2/usr/lib64/python2.7/Tools/scripts/mailerdaemon.pytparsedirsj                 ) cCsd}ttjdkrAtjddkrAd}tjd=nttjdkr~x2tjdD]}t||qdWn td|dS(Niis-ds/ufs/jack/Mail/errorsinbox(RtsystargvRb(RQtfolder((s2/usr/lib64/python2.7/Tools/scripts/mailerdaemon.pytmains( t__main__i(s?----- The following addresses had permanent fatal errors ----- s(?P[^ ].*) ( .* )?(s8The following recipients did not receive your message: sK +(?P.*) (The following recipients did not receive your message: )?(t__doc__RRLR'RBRcRRRRR&RR4txRR(R,txlR$ttupleR%t IGNORECASERR6RR:RbRfRRd(((s2/usr/lib64/python2.7/Tools/scripts/mailerdaemon.pyts`     $        9   D