Current File : //lib/python2.7/site-packages/sos/sosreport.pyo
�
u��ec@sdZddlZddlZddlZddlZddlZddlmZddlmZm	Z	ddl
Zddlm
Z
mZddlmZddlZddlZddlmZmZddlZddlmZdd	lmZdd
lmZmZddlZddlmZddlm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)ddl*Z*dd
l+m,Z,m-Z-ej.ej/fZ0e1dd�Z2d�Z3de4fd��YZ5de	fd��YZ6dddgZ7d�Z8de4fd��YZ9d�Z:dS(sm
Gather information about a system and report it using plugins
supplied for application-specific information
i����N(tdatetime(tArgumentParsertAction(tImporterHelpertSoSTimeoutError(trmtree(tThreadPoolExecutortTimeoutError(t_sos(t__version__(t
_arg_defaultst
SoSOptions(tTarFileArchive(
tReporttSectiontCommandt
CopiedFiletCreatedFiletAlerttNotetPlainTextReportt
JSONReportt
HTMLReport(tziptinputs, cCs�g}|}|r%t|�d}nd}xX|D]P}t|�t|�t|�dkrt|j|�|}n|||}q2W|t|�|kr�|t|� }n|j|�|S(Nt tiH(tlentappend(t
first_linetitemstindenttseptlinestlinetnewlinetitem((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt_format_list3s
&
	
cCstjdj|�d�S(s� This function will format --since arg to append 0s if enduser
    didn't. It's used in the _get_parser.
    This will also be a good place to add human readable and relative
    date parsing (like '2 days ago') in the future s{:<014s}s%Y%m%d%H%M%S(Rtstrptimetformat(tdate((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt
_format_sinceEstTempFileUtilcBs#eZd�Zd�Zd�ZRS(cCs||_g|_dS(N(ttmp_dirtfiles(tselfR+((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt__init__Os	cCsGtjd|j�\}}tj|d�}|jj||f�|S(Ntdirsw+(ttempfiletmkstempR+tostfdopenR,R(R-tfdtfnametfobj((s1/usr/lib/python2.7/site-packages/sos/sosreport.pytnewSscCsxxh|jD]]\}}y|j�|j�Wntk
rAnXytj|�Wq
tk
rfq
Xq
Wg|_dS(N(R,tflushtcloset	ExceptionR2tunlink(R-R5tf((s1/usr/lib/python2.7/site-packages/sos/sosreport.pytcleanZs


(t__name__t
__module__R.R7R=(((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyR*Ms		t
SosListOptioncBseZdZdd�ZRS(s0Allow to specify comma delimited list of pluginscCsdg|jd�D]}|^q}t||j�rM|t||j�7}nt||j|�dS(Nt,(tsplittgetattrtdesttsetattr(R-tparsert	namespacetvaluest
option_stringtoptR((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt__call__ls"N(R>R?t__doc__tNoneRK(((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyR@hstautotalwaystneverc
Csd}td|�}|jddt�|jdddddd	d
tdd�|jd
ddddd
tdd�|jdddddd
d�dtdd�|jdddddd
tdd�|jdddddd
tdd�|jddddddd�|jdddddd dd!d
td �|jd"dtdddd#d
d$dd%�|jd&dddd'dd(�|jd)d*dtdddd+d
d,�|jd-dddd.�|jd/dddd0d
tdd1�|jd2d3dddd4dtdd5d
g�|jd6d7dddd8dtdd9d
g�|jd:d;dddd<dd=�|jd>d?dddd@d
tddA�|jdBddddC�|jdDddddEd
tddF�|jdGddddHdt	d
tdHddI�|jdJdKddddLdtddMd
g�|jdNddddOddPd
t�|jdQddd
tddRddS�|jdTd
tddUddddV�|jdWdtddd
d,ddX�|jdYdZdddd[dtdd\d
g�|jd]dddtdd^d
d_�|jd`d
d�dda�|jdbdcddddddtd
gdde�|jdfdgddddhd
tddi�|jdjdkddddlddmd
d��|jdnddddddo�|jdpddddqddrd
d��|jdsdtdduddvd
tdvddw�f|jdxddddyd
tddz�|jd{d|dd}d
td}dd~�|jdd�dddd�dd�d
d�dt	�|jd�dddd�d
tdd��|jd�ddd
tdd��|jd�d
d�dd��|jd�d
d�dd��|jd�d
d�dd��|jd�d
d�dd��|jd�d
d_d�d_d�d�gdd��|jd�d
d_d�d_d�d�d�gdd��|j
�}|jd�dtdddd��|jd�dtdddd��|j
�}|jd�dd��|jd�dd��|S(�s Build ArgumentParser contents�%(prog)s [options]

Some examples:

enable dlm plugin only and collect dlm lockdumps:
  # sosreport -o dlm -k dlm.lockdump

disable memory and samba plugins, turn off rpm -Va collection:
  # sosreport -n memory,samba -k rpm.rpmva=offtusagetactiontextends-as--alloptionst
store_trueRDt
alloptionstdefaultthelps%enable all options for loaded pluginss
--all-logstall_logss-collect all available logs regardless of sizes--sincetstoretsincettypesbEscapes archived files older than date. This will also affect --all-logs. Format: YYYYMMDD[HHMMSS]s--batchtbatchs(batch mode - do not prompt interactivelys--buildtbuilds;preserve the temporary directory and do not package resultss	--case-idtcase_idsspecify case identifiers-cs--chroottchrootsHchroot executed commands to SYSROOT [auto, always, never] (default=auto)s
--config-filetconfig_files
/etc/sos.confs$specify alternate configuration files--debugtdebugs6enable interactive debugging using the python debuggers--descs
--descriptionsDescription for a new presetRs	--dry-runs#Run plugins but do not collect datas--experimentaltexperimentalsenable experimental pluginss-es--enable-pluginst
enablepluginssenable these pluginss-ks--plugin-optiontplugoptss7plugin options in plugname.option=value format (see -l)s--labels--nametlabels"specify an additional report labels-ls--list-pluginstlist_pluginss)list plugins and available plugin optionss--list-presetss#display a list of available presetss--list-profilest
list_profilessBdisplay a list of available profiles and plugins that they includes
--log-sizetlog_sizes)limit the size of collected logs (in MiB)s-ns--skip-pluginst	nopluginssdisable these pluginss--no-reporttnoreports disable plaintext/HTML reportings
--no-env-varstno_env_varss$Do not collect environment variabless
--no-postproctno_postprocsDisable all post-processings--notesBehaviour notes for new presets-os--only-pluginstonlypluginssenable these plugins onlys--presetsA preset identifierRNs--plugin-timeoutsset a timeout for all pluginss-ps	--profiletprofiless)enable plugins used by the given profiless-qs--quiettquietsonly print fatal errorss-ss	--sysroottsysroots(system root directory path (default='/')s--ticket-numbersspecify ticket numbers	--tmp-dirR+s%specify alternate temporary directorys-vs	--verbosetcountt	verbositysincrease verbositys--verifytverifys+perform data verification during collections-zs--compression-typetcompression_typesDcompression technology to use [auto, gzip, bzip2, xz] (default=auto)s-ts	--threadstthreadss7specify number of concurrent plugins to run (default=4)is--allow-system-changestallow_system_changessJRun commands even if they can change the system (e.g. load kernel modules)s--uploads/Upload the archive to a policy-default locations--upload-urls*Upload the archive to the specified servers--upload-directorys.Specify the directory to upload the archive tos
--upload-users.Username to authenticate to upload server withs
--upload-passs.Password to authenticate to upload server withs--upload-methodtchoicestputtposts HTTP method to use for uploadings--upload-protocolthttpstftptsftps$Manually specify the upload protocols--add-presets#Add a new named command line presets--del-presets$Delete the named command line presets
--encrypt-keys.Encrypt the final archive using a GPG key-pairs--encrypt-passs*Encrypt the final archive using a passwordN(RtregisterR@tadd_argumenttFalseRMR)R
tstrtinttadd_mutually_exclusive_group(tusage_stringRFt
preset_grptencrypt_grp((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt_get_parserws









t	SoSReportcBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
ed	��Zd
d�Z
d�Zd6d6d
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!d!d"�Z#d#�Z$d$�Z%d%�Z&d&�Z'd'�Z(d(�Z)d)�Z*d*�Z+d+�Z,d,�Z-d-�Z.d.�Z/d/�Z0d0�Z1d1�Z2d2�Z3d3�Z4d4�Z5d5�Z6RS(7sThe main sosreport classc	Csg|_g|_g|_t�|_d|_d|_||_d|_	d|_
t|_d|_
y)ddl}|j|j|j��Wntk
r�nX|j�t�}t�j|jg��|_x,|jD]!}|jdkr�d|_q�q�Wt�j|j|��}|jj|�t�j||jj�|_|jj|j�|j�y"tj j!d|jj	�|_"Wnt#k
r�|j$d�nX|j"j%�|_&|jj
t'dkr6|j"j(|jj
�|_
|j
s6t)j*j+d|jj
�|j"j,�|_
t-|j_.q6n|j
sT|j"j,�|_
n|jj|j
j�t/j0j1|j"j2|jj3��}t/j0j4|�s�t/j5|t/j6�r�d|}|d	7}t)j*j+|�|j$d
�n||_
t7j8ddd
|j
�|_9t:|j9�|_|j;�|j<�d}|j"j=�}|jj	rqd}|jj	|_	n0|j"j>�r�|t/j?kr�d}||_	n|j@jAd|j	|f�|jjBtCkr|j@jDd|jjB�tEjF�|jjG�|j$d
�ndS(Nt/i����s==SUPPRESS==RpitpresetsUnknown preset: '%s'
stemporary directory %s s"does not exist or is not writable
itprefixssos.R/RVtcmdlinetpolicysset sysroot to '%s' (%s)sinvalid chroot mode: %s(Htloaded_pluginstskipped_pluginstall_optionstsettenv_varsRMtarchivet
tempfile_utilt_argsRptsys_tmpRtexit_processR�tsignaltSIGTERMtget_exit_handlerR:tprint_headerR�Rt	from_argst
parse_argstoptst_actionsRVtmerget	from_fileR`tfileoptst
_set_debugtsostpoliciestloadR�tKeyboardInterruptt_exittis_roott_is_rootR
tfind_presettsyststderrtwritetprobe_presettTruetlist_presetsR2tpathtabspathtget_tmp_dirR+tisdirtaccesstW_OKR0tmkdtempttmpdirR*t_set_directoriest_setup_loggingthost_sysroottin_containerR tsoslogRaR_tchroot_modesterrortloggingtshutdownR=(	R-targsR�RFtoptiontcmd_optsttmptmsgR�((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyR.s�										

	

"
		$

	



cCsdtdtf�GHdS(Ns
%s
ssosreport (version %s)(t_R	(R-((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyR��scCsai	|jd6|jd6|jd6|jd6|jd6|jd6|jd6|jjd6|jd	6S(
NtcmddirtlogdirtrptdirR�R�R�RpRrtcmdlineopts(	R�R�R�R�R�R�RpR�Rr(R-((s1/usr/lib/python2.7/site-packages/sos/sosreport.pytget_commons�s







cCs
|jj�S(N(R�R7(R-((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt
get_temp_file�scCs
i|jjs|jjr!tntd6|jjd6|jjd6}tjj|j|j	j
��}|jjdkr�|j	j�}|||j|j	|jj
||j�|_n-t||j|j	|jj
||j�|_|jj|jjr�tnt�dS(NtencrypttkeytpasswordRN(R�tencrypt_passtencrypt_keyR�RR2R�tjoinR�R�tget_archive_nameRttget_preferred_archiveRuRpR�Rt	set_debugRa(R-tenc_optstarchive_nametauto_archive((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt_set_archive�s 
cCsF|jj|jd�|jj|jd�|jj|jd�dS(Ni�(R�tmakedirsR�R�R�(R-((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt_make_archive_paths�scCsd|_d|_d|_dS(Ntsos_commandstsos_logstsos_reports(R�R�R�(R-((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyR��s		cCs1|jjr$|jt_t|_n	t|_dS(N(R�Rat
_exceptionR�t
excepthookR�t
raise_pluginsR(R-((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyR��sc	Csottd�stjj�r5tj|||�n6tj|||dddtj�tj	�t
j�dS(s* Wrap exception in debugger if not in tty tps1tlimititfileN(thasattrR�R�tisattyt__excepthook__t	tracebacktprint_exceptiontstdouttsixtprint_tpdbtpm(tetypeteval_tetrace((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyR��s

icCst|��dS(N(t
SystemExit(R-R�((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyR��scs�fd�}|S(Ncst�_�j�dS(N(R�R�R�(tsignumtframe(R-(s1/usr/lib/python2.7/site-packages/sos/sosreport.pytexit_handler�s	((R-R�((R-s1/usr/lib/python2.7/site-packages/sos/sosreport.pyR��scCs�|js|jr]tj�\}}}tj|||dtj�tj�t	j
|�n|r||r||j||�ndS(NR�(R�R�R�texc_infoR�R�R�R�R�R�tpost_mortemt_log_plugin_exception(R-tplugnametfuncR�tvalttb((s1/usr/lib/python2.7/site-packages/sos/sosreport.pythandle_exception�s
cCsdtjd�|_|jjtj�|j�|_tj|j�}|jtj	d��|jtj
�|jj|�|jj
s�tjtj�}|jtj	d��|jjr�|jjdkr�|jtj�|jtj�nQ|jjr2|jjdkr2|jtj
�|jtj�n|jtj�|jj|�tjtj�}|jtj	d��|jtj�|jj|�ntjd�|_|jjtj
�|j�|_tj|j�}|jtj	d��|jj|�|jj
s`tjtj�}|jtj	d��|jtj
�|jj|�ndS(NR�s&%(asctime)s %(levelname)s: %(message)ss%(message)siitsos_ui(R�t	getLoggerR�tsetLeveltDEBUGR�tsos_log_filet
StreamHandlertsetFormattert	FormattertINFOt
addHandlerR�RoR�R�RrtWARNINGR�tERRORtui_logtsos_ui_log_file(R-tflogtconsoletconsole_errtui_fhandlert
ui_console((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyR��sF

cCs~t|dd�r=|jj|jdtjjdd��nt|dd�rz|jj|jdtjjdd��ndS(NRRDR�ssos.logRsui.log(	RCRMR�tadd_fileRR2R�R�R(R-((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt
_add_sos_logsscCs�|jj}t|jj�s"tSt|d�s5tS|rU|j|j��rUtSt	g|jD]}||jjk^qb�S(NRn(
R�RmRRnR�R�Rt_is_not_specifiedtnametany(R-tplugin_classRmtp((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt_is_in_profilescCs||jjkS(N(R�Ri(R-tplugin_name((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt_is_skipped(scCs;||j��j�o:||jjko:||jjkS(N(R�t
check_enabledR�RcRm(R-RtpluginClass((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt_is_inactive+scCs;||j��j�o:||jjko:||jjkS(N(R�tdefault_enabledR�RcRm(R-RR((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt_is_not_default0scCs|jjo||jjkS(N(R�Rm(R-R((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyR5stunknowncCs/|jj|j�||j��|f�dS(N(R�RRR�(R-Rtreason((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt_skip9s		cCs,|jj|j�||j��f�dS(N(R�RRR�(R-R((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt_load@s		cCs�tjj}ttj�}|j�}g|_t�|_t|j	j�}|j
j}g}|j	jr�|j
tjj�nt||�}|j
j}t|j	j�}	x�|D]�}
tjj|
�\}}yK|||�}
t|
�s�w�n|j
j|
�}||d|j	j�sn|jjtd�|
�|j	jdkrn|j|td��w�qnn|jr�|jr�|jjtd�|
�|j|td��w�n|jj
|�|j|�}|s�|j|td��w�n|j|�r#|j|td��w�n|j ||�rQ|j|td	��w�n|j!||�r|j|td
��w�nt"|d�r�|jj#|j�n|o�|}|j$|�r�|r�|j|td��w�nx-|jD]"}||	kr�|	j%|�q�q�W|j&|�Wq�t'k
r_}|jjtd
�|
|f�|j(�q�Xq�Wt|	�dkr�|jj)td�dj*|	��|j+�|j,d�ndS(NRbs%plugin %s does not validate, skippingisdoes not validates7plugin %s requires root permissionsto execute, skippings
requires roottexcludedtskippedtinactivetoptionalRns
not specifieds(plugin %s does not install, skipping: %ss+Unknown or inactive profile(s) provided: %ss, i(-R�tpluginst
import_pluginRtget_modulestplugin_namesR�RnRR�R�tvalid_subclassesRbRtExperimentalPluginttupletvalidate_plugintlistR2R�tsplitexttmatch_pluginR�twarningR�RrR#t
requires_rootR�tinfoRRRR R�tupdateRtremoveR$R:R�R�R�RgR�(R-R*thelperR)tusing_profilestpolicy_classest
extra_classestvalid_plugin_classesR0tremaining_profilestplugtplugbasetexttplugin_classesRt
in_profiletdefault_profiletite((s1/usr/lib/python2.7/site-packages/sos/sosreport.pytload_pluginsFs�	
			

cCsv|jjrrxc|jD]U\}}xFt|j|j�D]/\}}t|d�tkr8t|d<q8q8WqWndS(Ntenabled(	R�RUR�Rt	opt_namest	opt_parmsR[tboolR�(R-R�R?Rtparms((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt_set_all_options�s
"cCs�|jjr�i}x|jjD]�}y|jd�\}}Wntk
rWt}n@X|j�dkrst}n$yt|�}Wntk
r�nXy|jd�\}}Wntk
r�|}t}nXy||Wntk
r�g||<nX||j	||f�qWx�|j
D]y\}}||krxT||D]H\}}|j||�sB|jj
d||f�|jd�qBqBW||=qqWx(|j�D]}|jj
d	|�q�W|j�r�|jj
d
�q�ndS(Nt=tofftdisabletdisabledtfalset.s#no such option "%s" for plugin (%s)isFWARNING: unable to set option for disabled or non-existing plugin (%s)R(RORPRQRR(R�RdRBt
ValueErrorR�tlowerRR�tKeyErrorRR�t
set_optionR�R�R�tkeys(R-R�RJR�R?R�((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt
_set_tunables�sH

	



cCs�ddl}xu|j|jj|jj|jj�D]L}|jd�d}||jkr4|jj	d|�|j
d�q4q4WdS(Ni����RSis<a non-existing plugin (%s) was specified in the command linei(t	itertoolstchainR�RmRiRcRBR,R�tfatalR�(R-RZtpluginR((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt_check_for_unknown_plugins�s	cCslxe|jD]Z\}}|j�\}}x9t||�D](\}}|jj||||f�q8Wq
WdS(N(R�tget_all_optionsRR�R(R-RR]tnamesRLtoptnametoptparm((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt_set_plugin_options�s
cCs|jjd�t|j�rN|jjdt|j�t|j�f�n|jjdt|j��|jjd�dS(NRs %d profiles, %d pluginss %d profiles(RR6RR�Rn(R-((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt_report_profiles_and_plugins�s#cCs�|jr.|jr.|jjtd��dS|jr�|jjtd��|jjd�xP|jD],\}}|jjd||j�f�qgWn|jjtd��|jjd�|jr2|jjtd��|jjd�x@|jD]2\}}}|jjd|||j�f�q�Wn|jjd�|jro|jjtd��xE|jd	d	j	D]/}|jjd
|d	|d|df�qvW|jjd�|jjtd
��x�|jD]�\}}}}|dkr�q�nt
|d�tkr5|dtkr,d}q?d}n
|d}|jjd
|d|||df�q�Wn|jjtd��|jjd�t
|j�}	|	j�td|	dt�}
x"|
D]}|jjd|�q�W|j�dS(Nsno valid plugins founds,The following plugins are currently enabled:Rs	 %-20s %ssNo plugin enabled.s-The following plugins are currently disabled:s %-20s %-14s %ss4The following options are available for ALL plugins:is %-25s %-15s %siis+The following plugin options are available:ttimeouttpostprocRHtonRORStdescsNo plugin options available.s
Profiles: Rs %s(stimeoutspostproc(R�R�R�R\R�RR6tget_descriptionR�t_default_plug_optsR[RKR�R1RntsortR%Rd(R-R�R?t	plugclassR"RJRaRbttmpoptRnR!R"((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyRf�sX			-		
$

c	Cs|js#|jjtd��dS|jjtd��|jjd�d�}t|j�}|j�x�|D]�}g}xB|jD]7\}}||�r�||jkr�|j	|�q�q�Wt
d||dt�}x"|D]}|jjd|�q�WqrW|j�dS(Nsno valid profiles founds%The following profiles are available:RcSs
t|d�S(NRn(R�(tc((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt	_has_prof0ss%-15s Rs %s(
RnR�R\R�RR6R1RkR�RR%R�Rd(	R-RoRntprofileR)RR]R!R"((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyRg)s"		


cCsd|jjs&|jjtd��dS|jjtd��|jjd�x|jjj�D]�}|sqq_n|jj|�}|jjdd|j	f�|jjdd|j
f�|jr�|jjdd|jf�n|jj
dkrL|jj�}d}t||dtdd
�}x!|D]}|jj|�q/Wn|jjd�q_WdS(Nsno valid presets founds$The following presets are available:Rs%14s %ssname:sdescription:snote:is%14s soptions:RR Rs      options: (R�tpresetsR�R\R�RR6RXR�RRhtnoteR�Rrtto_argsR%R�(R-R�R�toptions_strR!R"((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyR�?s(	 
RcCs|j}|j|�r0|jjd|�tS|p?|jj}|pQ|jj}y)|jd|d|d|d|j�Wn(t	k
r�}|jjd|�tSX|j
jd�}|j
d|!|j
|d	}|jjd
|dj
|�f�tS(s�Add a new command line preset for the current options with the
            specified name.

            :param name: the name of the new preset
            :returns: True on success or False otherwise
        s"A preset named '%s' already existsRRhRrR�sCould not add preset: %ss--add-presetiis"Added preset '%s' with options %s
R(R�R�RR�RR�RhRrt
add_presetR:R�tindexR6R�R�(R-RRhRrR�RFt	arg_indexR�((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyRuWs 	)cCs�|j}|j|�s0|jjd|�tSy|jd|�Wn.tk
rt}|jjt|�d�tSX|jjd|�t	S(s�Delete a named command line preset.

            :param name: the name of the preset to delete
            :returns: True on success or False otherwise
        sPreset '%s' not foundRs
sDeleted preset '%s'
(
R�R�RR�Rt
del_presetR:R�R6R�(R-RR�RF((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyRxts	cCs�|jjr(|jj|jj��n�|jj�}|td�7}yt|�Wnotk
r�}|jj	d�|j
d�n@tk
r�}|jjd�|jj	|�|j
|�nXdS(Ns,Press ENTER to continue, or CTRL-C to quit.
sExiting on user canceli�R(R�R\RR6R�tget_msgR�RR�R�R�R:(R-R�RF((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyR\�scCs�tj�}d}d|}tjj|j|�}|jjd|||f�|jjd|�|jj	d||dd�dS(Ns!caught exception in plugin methods%s-plugin-errors.txts%s "%s.%s()"swriting traceback to %ss%s
tmodeta(
R�t
format_excR2R�R�R�R�R�R�t
add_string(R-R]tmethodttraceR�tplugin_err_logtlogpath((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyR��s
cCsq|jj�y�|jjtd��d}|jj}||kr�dj|�}|jjd�|jjd|�|jjd	|�|jjd�|j	d
�n|j
�|j�dSWn�tt
fk
r}|jtkrdGHd|jGHdGHq`d|GH�nMtk
r_}|jjd�|jjd
�tj�|jj|�nX|j	d
�dS(Ns Setting up archive ...RNtbzip2tgziptxzs, RsInvalid compression specified: sValid types are: is %s while setting up archivesError setting up archive: %ss) Unexpected exception setting up archive:(sautoR�R�R�(R�tpre_workRR6R�R�RtR�R�R�R�R�tOSErrortIOErrorterrnotfatal_fs_errorststrerrorR:R�t	print_exc(R-tcompression_methodsR~tcompression_listRF((s1/usr/lib/python2.7/site-packages/sos/sosreport.pytprework�s8


	
cCsd}|jj|tddj|j�f�d}|jj|tddj|jj��f�|jjj�}dtd|jj	dj|�f}|jj|�|jjdtddj|jj��f�|j
jtd��x|jD]\}}yP|j
|_
|j�|j�|jj|j�|jjrU|j�nWq�tk
rl�q�ttfk
r�}|jtkr�|j
jd�|j
jd	|j�|j
jd�|jd
�n|j|d�q�tk
r
|j|d�q�Xq�WdS(Ns [%s:%s] executing 'sosreport %s'tsetupRs,[%s:%s] loaded options from config file: %s's'[%s:%s] using '%s' preset defaults (%s)s![%s:%s] effective options now: %ss Setting up plugins ...Rs %s while setting up pluginsi(R�R6R>R�R�R�RsR�R�RRR�R�R�tadd_default_collectionsR�R�R7t	_env_varsRstsetup_verifyR�R�R�R�R�R�R�R�R�R:(R-R�tpreset_argsR�R?RF((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyR��s@)"#



cCsqg}|jdt�x1|jD]&\}}|jd||jf�q!W|jjddj|�dd�dS(sWFetch version information from all plugins and store in the report
        version files
sosreport: %ss%s: %stcontents
RDsversion.txtN(RR	R�tversionR�R}R�(R-tversionsR�R?((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyR��scCs6|jjtd��|jjd�d}g|_g|_x5|jD]*}|d7}|jj||df�qHWy�t|jj	�|_
|j
j|jt
|j��}|j
jdt�x+|D]#}|s�|jjd|�q�q�W|jjd�Wn.tk
r1|jjd�tjd�nXdS(Ns! Running plugins. Please wait ...Riitwaits!Unexpected plugin task result: %ss
Exiting on user cancel
(RR6R�tpluglistt
running_plugsR�RRR�Rutplugpooltmapt_collect_pluginR1R�R�R�RaR�R�R2R�(R-tplugruncountREtresultstres((s1/usr/lib/python2.7/site-packages/sos/sosreport.pytcollect�s*		


c	Cs�td���}yK|j|j|�}|j|dddjpFd}|jd|�Wnftk
r�|jj	d|d�|j
j|d�t|j|ddd_
|jj�nXWdQXtS(saWraps the collect_plugin() method so we can apply a timeout
        against the plugin as a wholeiiRes
 Plugin %s timed out
N(Rtsubmittcollect_pluginR�ReRMtresultRRR�R�R8R�t_timeout_hitt_threadstclear(R-R]tpoolttRe((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyR�s"
c	Cs!y5|\}}|j|dd}|jj|�Wntk
rItSXt|j�}dd||f|ddjd�|jD��f}|j|�y�|j�y|j	j
|�Wntk
r�nXy|jj
|�Wntk
r�nXd}t|j	�t|j
j�krW|jrWddddjd	�|jD��f}n|jrt|j	rtd
}n|r�|j|�nWn�tk
r�nttfk
r�}|jtkr�|jjd|j�|jd�n|j|d�n!tk
r|j|d�nXdS(
Nis  Starting %-5s %-15s %ss%d/%ds
[Running: %s]Rcss|]}|VqdS(N((t.0R((s1/usr/lib/python2.7/site-packages/sos/sosreport.pys	<genexpr>/sRs  Finishing plugins %-12s %scss|]}|VqdS(N((R�R((s1/usr/lib/python2.7/site-packages/sos/sosreport.pys	<genexpr>Dss
  Finished running pluginss"
 %s while collecting plugin data
R�(R�R�RR:RRR�tui_progressR�R�R8RTR�R�RuRR�R�R�R�RR�R�R�R�(	R-R]RqR�R?tnumplugststatus_linetstatusRF((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyR�$sT

$



!	'	

cCso|jjdkr5|jjr5d|jd�}n
d|}|jjsktjj|�tjj�ndS(Nis
%siZs%s
(	R�RrR\tljustRoR�R�R�R8(R-R�((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyR�Ws
cCs�|js
dSdjgg|jD]:}tjj|�dk	r |dtjj|�f^q D]\}}d||f^q^�d}|jj|d�dS(Ns
s%ss%s=%stenvironment(R�R�R2tenvirontgetRMR�R}(R-RR�tenv((s1/usr/lib/python2.7/site-packages/sos/sosreport.pytcollect_env_vars`s	ZcCs�t�}x]|jD]R\}}td|�}x$|jD]}|jt|��q8W|jrw|jt|j��nx9|jD].}|jt	d|ddd|d��q�WxW|j
D]L}|jtd|ddddtj
jd|j�d	|d
���q�WxH|jD]=\}}|jtd|dtj
jdd||���qW|j|�qWtdd
ftddftddff}	x�|	D]�\}
}}y^|j�}
|
|�j�}|
j|�|
j�|jj|
dtj
jd|��Wq�ttfk
r~}|jtkr|jj d�|jj d|j!|f�|jj d�|j"d�qq�Xq�WdS(NRtsrcpaththrefs..tdstpathtcmdtreturn_codeiR�R�tsos_stringsssos.txtttextssos.jsontJSONssos.htmltHTMLRDR�Rs %s while writing %s reporti(#R
R�RtalertstaddRtcustom_textRtcopied_filesRtexecuted_commandsRR2R�R�R�tcopy_stringsRRRRR�tunicodeR�R8R�RR�R�R�R�RR�R�R�(R-treportR�R?tsectiontalertR<R�R�t
formatlisttclass_tfilenamettype_R4toutputRF((s1/usr/lib/python2.7/site-packages/sos/sosreport.pytgenerate_reportsjsT			
	

cCs�x�|jD]�\}}y4|jd�r5|j�n|jjd|�Wq
ttfk
r�}|jtkr�|j	j
d�|j	j
d|j�|j	j
d�|jd�n|j
|d�q
tk
r�|j
|d�q
Xq
WdS(NRfsSkipping postproc for plugin %sRs% %s while post-processing plugin datai(R�t
get_optionRfR�R6R�R�R�R�RR�R�R�R�R:(R-R�R?RF((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyRf�s 

cCs�|s
tSyed}t|d�}tj|�}x0trc|j|�}|sSPn|j|�q4W|j�Wntk
r�|j	�nX|j
�S(Niitrbi(RtopenthashlibR7R�treadR7R9R:R�t	hexdigest(R-R�t	hash_namet	hash_sizet
archive_fptdigestthashdata((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt_create_checksum�s	
cCs?t|d|d�}|r1|j|d�n|j�dS(NRStws
(R�R�R9(R-R�R�tchecksumtfp((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt_write_checksum�scCs|j�d}d}|jjstjd�}|jjsKtd�GHnz�y|jj	|jj
�}Wn�ttfk
r�}dGHtd|j
|jj�f�GHdGH|jtkr�|jd�q�n'tk
r�|jjr��q�tSnXWdtj|�Xn}|jj�}tjj|�}y2tjj|j|�}tj||�|}Wn'ttfk
r�td|�GHtSXd}|jjs�|s�dGHq�|jj�}|j||�}y|j|||�Wn&ttfk
rtd|�GHnXtjj|jtjj|��}	tj|�}
|d	|}|	d	|}ytj||	�|	}Wn'ttfk
r�td
|�GHtSXytj||�Wq�ttfk
r�td|�GHq�Xn|jjs|jj||||
�n|jj|||�|jj s2|jj!r�|jjs�y*|jj"|�|j#j$td��Wq�tk
r�}
|j#j%d
|
�q�Xq�d}|j#j%|�nt&j'�|j(r�|j(j)�n|j*r�tjj+|j*�r�t,|j*�nt-S(Ni?sCreating compressed archive...Rs %s while finalizing archive %sisError moving directory: %ss Creating archive tarball failed.s#Error writing checksum for file: %sRSsError moving archive file: %ssError moving checksum file: %ssUploaded archive successfullysUpload attempt failed: %ssEUnable to upload archive when using --build as no archive is created.(.RRMR�R]R2tumaskRoR�R�tfinalizeRtR�R�R�tget_archive_pathR�R�R�R:RaRR�tbasenameR�R�trenameR�tget_preferred_hash_nameR�R�tstattdisplay_resultstuploadt
upload_urltupload_archiveRR6R�R�R�R�R=R�R�RR�(R-R�t	directoryt	old_umaskRFtdir_namet	final_dirR�R�t
final_nametarchivestattarchive_hasht
final_hashterrR�((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt
final_work�s�
	




	cCs'|js#|jjtd��tStS(Nsno valid plugins were enabled(R�R�R�R�RR�(R-((s1/usr/lib/python2.7/site-packages/sos/sosreport.pytverify_pluginsJs	cCsO|jr|jj�n|jr2|jj�n|jrKt|j�ndS(N(R�tcleanupR�R=R�R(R-((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt_cleanupPs			cCs2y�|jj|j��|j�|j�|j�|j�|j�|jj	rj|j	�t
�n|jjr�|j�t
�n|jjr�|j�t
�n|jj
r�|j
|jj
�S|jjr�|j|jj�S|j�s�tS|j�|j�|j�|j�|jjs7|j�n|jjsP|j�n|jjsi|j�n|jjd�|j�|j�SWn�tk
r�|jj r��n|j!�ndt"k
r�|jj#d�|j!�|j$d�n-t
k
r }|j!�t%j&|j'�nX|j$d�dS(Ns)Skipping postprocessing of collected datas
Exiting on user canceli�i((R�tset_commonsR�RGRMRYR^RcR�RfR�RgR�RuRxR�RR\R�R�R�RkR�RjR�RlRfRR6R�R�R�RaR�R�R�R�R�texittcode(R-RF((s1/usr/lib/python2.7/site-packages/sos/sosreport.pytexecuteZs^





	
	
	












N(7R>R?RLR.R�R�R�R�R�R�R�tstaticmethodR�R�R�RMR�R�RRRRR RR#R$RGRMRYR^RcRdRfRgR�RuRxR\R�R�R�R�R�R�R�R�R�R�RfR�R�R�R�R�R�(((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyR�sf	g		
							-		
						U		0			
	;							"	)	
			3			
	9				{		
cCst|�}|j�dS(sThe main entry pointN(R�R�(R�R�((s1/usr/lib/python2.7/site-packages/sos/sosreport.pytmain�s(;RLR�R�R2R�R�RtargparseRRtsos.pluginsR�t
sos.utilitiesRRtshutilRR0R�tconcurrent.futuresRRR�RR�R	R
Rtsos.policiestsos.archiveRt
sos.reportingR
RRRRRRRRRR�t	six.movesRRtENOSPCtEROFSR�RR%R)tobjectR*R@R�R�R�R�(((s1/usr/lib/python2.7/site-packages/sos/sosreport.pyt<module>sFF		�����{