v_c@sdZddlZddlZdefdYZdZdZdZdZd Z d Z d Z y e Wnek rZ nXe d krd dZejdndZdS(s- Module for the ABRT exception handling hook iNt RPMinfoErrorcBseZdZRS(s1Exception class for RPMdb-querying related errors(t__name__t __module__t__doc__(((s</usr/lib64/python2.7/site-packages/abrt_exception_handler.pyRscCs/ddlm}y|j|WnnXdS(s&Log message to system logger (journal)i(tjournalN(tsystemdRtsend(tmsgR((s</usr/lib64/python2.7/site-packages/abrt_exception_handler.pytsyslog s cCstjdddkr3tjjtjd}n tjd}d}|ryddl}t|}Wqtk r}t dqXnyddl }|j |j |j }|j dy=|jdd|jd|jd |jd tj|jd ||jd |jd|jd ||rd|jddj|n|jdx4tjjD]#\}} |jd|| fqW|jd|j|jd} x-tr|jd} | sPn| | 7} qWWn*|jk r(} t dt| nX|j| j} t| dks| djd s| dj st | ddkrt d| nWn't!k r} t dt| nXdS(Nit/is?RPM module not available, cannot query RPM db for package namesis/var/runs/abrt/abrt.socketsPOST / HTTP/1.1 s type=Pythonspid=%ssexecutable=%ss reason=%ss backtrace=%ss dso_list=%ss senviron=s%s=%s ttis)communication with ABRT daemon failed: %sisHTTP/iis%error sending data to ABRT daemon: %ss5can't communicate with ABRT daemon, is it running? %s("tsystargvtostpathtabspathtNonetrpmt get_dso_listt ImportErrorRtsockettAF_UNIXt SOCK_STREAMt settimeouttconnecttsendalltgetpidt splitlinestjointenviront iteritemstshutdowntSHUT_WRtTruetrecvttimeouttstrtclosetsplittlent startswithtisdigittintt Exception(ttb_textttbt executabletdso_listRtimperrRtstktvtresponsetbuftextparts((s</usr/lib64/python2.7/site-packages/abrt_exception_handler.pyt write_dump1s\           cCsddl}|j}|jd|}y|j}Wn!tk r]td|nXdj|d|d|d|d }|S( s Returns package name for a given file. @param fpath: filename @type fpath: str @return: package name for the file @rtype: str @throws RPMinfoError: if package for the file cannot be found iNt basenamess*Cannot get package and component for file s{0}-{1}-{2}.{3}tnametversiontreleasetarch(RtTransactionSettdbMatchtnextt StopIterationRtformat(tfpathRttstmitheadertpackage((s</usr/lib64/python2.7/site-packages/abrt_exception_handler.pytget_package_for_filess   c Csddl}|j|r-|j|}nt}xP|D]H\}}}}}}y|jt|Wq=tk r} q=q=Xq=Wy|jttj dWntk r} nXt |S(s Get the list of names of the packages whose files appear in the traceback. @param tb: traceback @type tb: traceback @return: list of package names @rtype: list iNi( tinspectt istracebacktgetinnerframestsettaddRIRtdiscardR R tlist( R.RJtpackagestframeRDtlinenotfunctctxtidxtrpmerr((s</usr/lib64/python2.7/site-packages/abrt_exception_handler.pyRs   cCsJddl}y|jd}Wntk r3tSX|jdddkS(sR Return True if absolute path requirement is enabled in configuration iNs python.conftRequireAbsolutePathtyes(tproblemtload_plugin_conf_filetOsErrortFalsetget(RZtconf((s</usr/lib64/python2.7/site-packages/abrt_exception_handler.pytrequire_abs_paths   c Cs6|\}}}y tjt_ddl}|ttgkrOtj|||S|tksg|tkr|j|jkrtj|||Sntj d stj dddkrtj dsdndtj d}t d|t nt dtj dtj ddd kr0t r0t q0nddl }|j|||}|dkr|tkr|j|d d}t|r|t|d }n|j||} |rt|d krg} | j|d tjj|d| d<| }nd} x"|D]} | t| d 7} qW| } | | d7} | d7} | dj|7} |}x|jr|j}qjW|j}| d7} y>x7|jjD]&\}}| d|t|f7} qWWq q Xn-t|d} | d7} | dj|7} t| |WnnXtj|||S(s The exception handling function. progname - the name of the application version - the version of the application iNit-R s (python %s ...)s;detected unhandled Python exception in 'interactive mode%s's+detected unhandled Python exception in '%s'R tlimitiit:s s% Local variables in innermost frame: s%s: %s ( R t__excepthook__t excepthookterrnotKeyboardInterruptt SystemExittIOErrortOSErrortEPIPER RR,R`t tracebacktformat_exceptionRtIndentationErrort extract_tbR(tformat_exception_onlytextendRRtbasenameR%Rttb_nextttb_frametf_localstitemstreprR9(t.0tetypetvalueR.RfteinfoRltelistttblasttextxttlltntextttttextttraceRRtkeytval((s</usr/lib64/python2.7/site-packages/abrt_exception_handler.pythandleMyExceptionsl    %$            " cCsdt_dS(s2 Install the exception handling function. cSst|||fS(N(R(RyRzR.((s</usr/lib64/python2.7/site-packages/abrt_exception_handler.pyt!sN(R Re(((s</usr/lib64/python2.7/site-packages/abrt_exception_handler.pytinstallExceptionHandlerst__main__iis Harald Hoyer (RR RR,RRR9RIRR`RRteRtdiv0texitt __author__(((s</usr/lib64/python2.7/site-packages/abrt_exception_handler.pyts$    B    c