Ñò K<Ì]c@s?ddkZddkZddkZddkZddkZddkZddkZddkZddkZddk Z ddk l Z l Z ddk lZlZyddkZWnej onXdefd„ƒYZdefd„ƒYZdeifd „ƒYZd efd „ƒYZd efd „ƒYZdS(iÿÿÿÿN(tPopentPIPE(tsos_get_command_outputt is_executabletArchivecBsËeZdZed„ƒZeidƒZdZe Z d„Z d„Z d„Z d„Zd„Zd „Zdd „Zd „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„ZRS(s!Abstract base class for archives.cCs|iS(s6Returns the archive class's name as a string. (t__name__(tclass_((s//usr/lib/python2.6/site-packages/sos/archive.pyt archive_type+stsostunsetcCsd|iƒ|fS(Ns[archive:%s] %s(R(tselftmsg((s//usr/lib/python2.6/site-packages/sos/archive.pyt _format_msg6scCs ||_dS(N(t_debug(R tdebug((s//usr/lib/python2.6/site-packages/sos/archive.pyt set_debug9scCs|ii|i|ƒƒdS(N(tlogterrorR (R R ((s//usr/lib/python2.6/site-packages/sos/archive.pyt log_error<scCs|ii|i|ƒƒdS(N(RtwarningR (R R ((s//usr/lib/python2.6/site-packages/sos/archive.pytlog_warn?scCs|ii|i|ƒƒdS(N(RtinfoR (R R ((s//usr/lib/python2.6/site-packages/sos/archive.pytlog_infoBscCs,|ipdS|ii|i|ƒƒdS(N(R RRR (R R ((s//usr/lib/python2.6/site-packages/sos/archive.pyt log_debugEs cCs t‚dS(N(tNotImplementedError(R tsrctdest((s//usr/lib/python2.6/site-packages/sos/archive.pytadd_fileMscCs t‚dS(N(R(R tcontentR((s//usr/lib/python2.6/site-packages/sos/archive.pyt add_stringPscCs t‚dS(N(R(R tsourcet link_name((s//usr/lib/python2.6/site-packages/sos/archive.pytadd_linkSscCs t‚dS(N(R(R tpath((s//usr/lib/python2.6/site-packages/sos/archive.pytadd_dirVscCs t‚dS(N(R(R R!tmodetdevice((s//usr/lib/python2.6/site-packages/sos/archive.pytadd_nodeYscCs t‚dS(s´Return a temporary directory that clients of the archive may use to write content to. The content of the path is guaranteed to be included in the generated archive.N(R(R ((s//usr/lib/python2.6/site-packages/sos/archive.pyt get_tmp_dir\scCs t‚dS(sºReturn the maximum file name length this archive can support. This is the lesser of the name length limit of the archive format and any temporary file system based cache.N(R(R ((s//usr/lib/python2.6/site-packages/sos/archive.pytname_maxbscCsdS(sTReturn a string representing the path to the temporary archive. For archive classes that implement in-line handling this will be the archive file itself. Archives that use a directory based cache prior to packaging should return the path to the temporary directory where the report content is locatedN((R ((s//usr/lib/python2.6/site-packages/sos/archive.pytget_archive_pathhscCsdS(s:Clean up any temporary resources used by an Archive class.N((R ((s//usr/lib/python2.6/site-packages/sos/archive.pytcleanupqscCs|iƒdS(sFinalize an archive object via method. This may involve creating An archive that is subsequently compressed or simply closing an archive that supports in-line handling. If method is automatic then the following methods are tried in order: xz, bz2 and gzipN(tclose(R tmethod((s//usr/lib/python2.6/site-packages/sos/archive.pytfinalizeusN(Rt __module__t__doc__t classmethodRtloggingt getLoggerRt_nametFalseR R RRRRRtNoneRRR R"R%R&R'R(R)R,(((s//usr/lib/python2.6/site-packages/sos/archive.pyR(s*              tFileCacheArchivecBs¹eZdZdZdZdZd„Zd„Zd„Zdd„Z d„Z d„Z d„Z d „Zd d „Zd „Zd „Zd„Zd d„Zd„Zd„Zd„ZRS(sd Abstract superclass for archive types that use a temporary cache directory in the file system. tcCsX||_||_tii||ƒ|_ti|idƒ|id|ifƒdS(NiÀs*initialised empty FileCacheArchive at '%s'(R2t_tmp_dirtosR!tjoint _archive_roottmakedirsR(R tnamettmpdir((s//usr/lib/python2.6/site-packages/sos/archive.pyt__init__†s    cCs?tii|ƒo|itiƒ}ntii|i|ƒS(N(R8R!tisabstlstriptsepR9R:(R R<((s//usr/lib/python2.6/site-packages/sos/archive.pyt dest_pathŽscCsJtii|ƒd}|pdStii|ƒp|i|ƒndS(Ni(R8R!tsplittisdirt _makedirs(R Rtdest_dir((s//usr/lib/python2.6/site-packages/sos/archive.pyt _check_path“s c Cs|p |}n|i|ƒ}|i|ƒyti||ƒWn,tj o }|id||fƒnXyti||ƒWntj onXy,ti |ƒ}ti ||i |i ƒWn,t j o }|id||fƒnX|id||ifƒdS(Nscaught '%s' copying '%s's%caught '%s' setting ownership of '%s's#added '%s' to FileCacheArchive '%s'(RBRGtshutiltcopytIOErrorRtcopystattOSErrorR8tstattchowntst_uidtst_gidt ExceptionRR:(R RRteRM((s//usr/lib/python2.6/site-packages/sos/archive.pyRšs&   cCså|}|i|ƒ}|i|ƒti|dddƒ}t|tƒo|iddƒ}n|i|ƒti i |ƒoGyt i ||ƒWqÇt j o }|id||fƒqÇXn|id||ifƒdS(Ntwtencodingsutf-8tutf8tignores*Unable to add '%s' to FileCacheArchive: %ss-added string at '%s' to FileCacheArchive '%s'(RBRGtcodecstopent isinstancetbytestdecodetwriteR8R!texistsRHRKRLRRR:(R RRRtfRR((s//usr/lib/python2.6/site-packages/sos/archive.pyR°s   cCsd|i|ƒ}|i|ƒtii|ƒpti||ƒn|id|||ifƒdS(Ns6added symlink at '%s' to '%s' in FileCacheArchive '%s'(RBRGR8R!R]tsymlinkRR:(R RRR((s//usr/lib/python2.6/site-packages/sos/archive.pyR Ás   cCs|i|ƒdS(N(R;(R R!((s//usr/lib/python2.6/site-packages/sos/archive.pyR"ÉscCsZ|i|ƒ}|i|ƒtii|ƒp'ti|||ƒti||ƒndS(N(RBRGR8R!R]tmknodRHRK(R R!R#R$R((s//usr/lib/python2.6/site-packages/sos/archive.pyR%Ìs  iÀcCsti||ƒdS(N(R8R;(R R!R#((s//usr/lib/python2.6/site-packages/sos/archive.pyREÓscCs9dtijo!tid}ti|i|ƒSdSdS(Nt PC_NAME_MAXiÿ(R8tpathconf_namestpathconfR:(R t pc_name_max((s//usr/lib/python2.6/site-packages/sos/archive.pyR'Ös cCs|iS(N(R:(R ((s//usr/lib/python2.6/site-packages/sos/archive.pyR&ÝscCs|iS(N(R:(R ((s//usr/lib/python2.6/site-packages/sos/archive.pyR(àscCs4|i|i|ƒƒ|id||ifƒdS(Ns2created directory at '%s' in FileCacheArchive '%s'(RERBRR:(R R!R#((s//usr/lib/python2.6/site-packages/sos/archive.pyR;ãs cCs%|i|ƒ}ti|dddƒS(NtrRTsutf-8(RBRWRX(R R!((s//usr/lib/python2.6/site-packages/sos/archive.pyt open_fileèscCsti|iƒdS(N(RHtrmtreeR:(R ((s//usr/lib/python2.6/site-packages/sos/archive.pyR)ìscCs®|id|i|fƒ|iƒ|iƒ|id|iti|iƒifƒ||_y|i ƒSWn9t j o-}d}|i d||fƒ|i ƒSXdS(Ns)finalizing archive '%s' using method '%s'sbuilt archive at '%s' (size=%d)s+An error occurred compressing the archive: s%s %s( RR:t_build_archiveR)t _archive_nameR8RMtst_sizeR+t _compressRQRR<(R R+RRtexp_msg((s//usr/lib/python2.6/site-packages/sos/archive.pyR,ïs    N(RR-R.R7R:RiR>RBRGR4RRR R"R%RER'R&R(R;RfR)R,(((s//usr/lib/python2.6/site-packages/sos/archive.pyR5~s(               t_TarFilecBseZdeddd„ZRS(c Cs%|idƒ|djo |}n|dj oIddk}|idtdƒ||ƒo|idd|ƒdSn|idj o5tii |ƒ|ijo|idd|ƒdS|id|ƒ|i ||ƒ}|djo|idd |ƒdS|dj o6||ƒ}|djo|idd|ƒdSn|i ƒoCt i |d ƒiiƒ}z|~} |i|| ƒWdQXnˆ|iƒom|i|ƒ|oUxRti|ƒD]=} |itii|| ƒtii|| ƒ|||ƒqËWq!n|i|ƒdS( s~Add the file `name' to the archive. `name' may be any type of file (directory, fifo, symbolic link, etc.). If given, `arcname' specifies an alternative name for the file in the archive. Directories are added recursively by default. This can be avoided by setting `recursive' to False. `exclude' is a function that should return True for each filename to be excluded. `filter' is a function that expects a TarInfo object argument and returns the changed TarInfo object, if it returns None the TarInfo object will be excluded from the archive. tawiÿÿÿÿNsuse the filter argument insteadistarfile: Excluded %rstarfile: Skipped %ristarfile: Unsupported type %rtrb(t_checkR4twarningstwarntDeprecationWarningt_dbgR<R8R!tabspatht gettarinfotisregttarfilet bltn_opent__exit__t __enter__taddfileRDtlistdirtaddR9( R R<tarcnamet recursivetexcludetfilterRqttarinfot_[1]R^((s//usr/lib/python2.6/site-packages/sos/archive.pyR~sD         ,      )  *N(RR-R4tTrueR~(((s//usr/lib/python2.6/site-packages/sos/archive.pyRmstTarFileArchivecBseeZdZd ZeZd„Zd d„Zd„Z d„Z d„Z d„Z d„Z d„ZRS( s: archive class using python TarFile to create tar archivescCsDtt|ƒi||ƒd|_tii||iƒƒ|_dS(Nttar( tsuperR†R>t_suffixR8R!R9R<Ri(R R<R=((s//usr/lib/python2.6/site-packages/sos/archive.pyR>Ls cCsp|i|_d|i|idR–RœR™R<R'RhRk(((s//usr/lib/python2.6/site-packages/sos/archive.pyR†Fs      tZipFileArchivecBsPeZdZd„Zd„Zd„Zdd„Zd„Zd„Z d„Z RS( s; archive class using python ZipFile to create zip archives c Csf||_yddk}ti|_Wnti|_nXti|iƒddd|iƒ|_dS(NiÿÿÿÿR#RSt compression(R2tzlibtzipfilet ZIP_DEFLATEDR°t ZIP_STOREDtZipFileR<(R R<R±((s//usr/lib/python2.6/site-packages/sos/archive.pyR>©s  cCs d|iS(Ns%s.zip(R2(R ((s//usr/lib/python2.6/site-packages/sos/archive.pyR<µscCs tt|ƒi|ƒ|iƒS(N(RˆR¯R,R<(R R+((s//usr/lib/python2.6/site-packages/sos/archive.pyR,¸scCst|ƒ}|ot|ƒ}ntii|ƒotid|ƒ}xµti|ƒD]r\}}}x`|D]X}di||fƒ}|o&|ii |ti |||ƒƒqo|ii |ƒqoWqYWn/|o|ii ||ƒn|ii |ƒdS(Nt^t/( tstrR8R!RDtretcompiletwalkR9R²R\tsub(R RRtregexR!tdirnamest filenamestfilename((s//usr/lib/python2.6/site-packages/sos/archive.pyR¼s" cCsZti|dtitiƒƒƒ}|i|_dtdƒ>|_|ii||ƒdS(Nt date_timeii( R²tZipInfottimet localtimeR°t compress_typetlongt external_attrtwritestr(R RRR((s//usr/lib/python2.6/site-packages/sos/archive.pyRÓs   cCsxzE|iiƒti|iƒddƒ|_|ii|ƒ}|SWd|iiƒti|iƒddƒ|_XdS(NR#Reta(R²R*RµR<RX(R R<tfile_obj((s//usr/lib/python2.6/site-packages/sos/archive.pyRfÚs  cCs|iiƒdS(N(R²R*(R ((s//usr/lib/python2.6/site-packages/sos/archive.pyR*äsN( RR-R.R>R<R,R4RRRfR*(((s//usr/lib/python2.6/site-packages/sos/archive.pyR¯¦s     (R8RÃRxR²RHR0tshlexR¹RWtsyst subprocessRRt sos.utilitiesRRRt ImportErrortobjectRR5tTarFileRmR†R¯(((s//usr/lib/python2.6/site-packages/sos/archive.pyts(          V†B`