Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/landscape/sysinfo/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/landscape/sysinfo/sysinfo.pyc

ó
ÍÿŠTc@s¬ddlZddlmZddlZddlZddlmZddlmZddl	m
Z
ddlmZdefd„ƒYZ
dddd	d
ddd
„ZdS(iÿÿÿÿN(t	getLogger(tFailure(tgather_results(tlog_failure(tPluginRegistrytSysInfoPluginRegistrycBsheZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z	d„Z
d	„Zd
„ZRS(sG
    When the sysinfo plugin registry is run, it will run each of the
    registered plugins so that they get a chance to feed information
    into the registry.

    There are three kinds of details collected: headers, notes, and footnotes.

    They are presented to the user in a way similar to the following:

        Header1: Value1   Header3: Value3
        Header2: Value2   Header4: Value4

        => This is first note
        => This is the second note

        The first footnote.
        The second footnote.

    Headers are supposed to display information which is regularly
    available, such as the load and temperature of the system.  Notes
    contain eventual information, such as warnings of high temperatures,
    and low disk space.  Finally, footnotes contain pointers to further
    information such as URLs.
    cCsDtt|ƒjƒi|_g|_g|_g|_t|_dS(N(	tsuperRt__init__t
_header_indext_headerst_notest
_footnotestFalset
_plugin_error(tself((s=/usr/lib/python2.7/dist-packages/landscape/sysinfo/sysinfo.pyR's				cCsd|jj|ƒ}|dkrMt|jƒ|j|<|jj||fƒn||f|j|<dS(sêAdd a new information header to be displayed to the user.

        Each header name is only present once.  If a header is added
        multiple times, the last value added will be returned in
        the get_headers() call.

        Headers with value None are not returned by get_headers(), but
        they still allocate a position in the list.  This fact may be
        explored to create a deterministic ordering even when dealing
        with values obtained asynchornously.
        N(RtgettNonetlenR	tappend(Rtnametvaluetindex((s=/usr/lib/python2.7/dist-packages/landscape/sysinfo/sysinfo.pyt
add_header/s
cCs*g|jD]}|ddk	r
|^q
S(s›Get all information headers to be displayed to the user.

        Headers which were added with value None are not included in
        the result.
        iN(R	R(Rtpair((s=/usr/lib/python2.7/dist-packages/landscape/sysinfo/sysinfo.pytget_headersBscCs|jj|ƒdS(s<Add a new eventual note to be shown up to the administrator.N(R
R(Rtnote((s=/usr/lib/python2.7/dist-packages/landscape/sysinfo/sysinfo.pytadd_noteJscCs|jS(s;Get all eventual notes to be shown up to the administrator.(R
(R((s=/usr/lib/python2.7/dist-packages/landscape/sysinfo/sysinfo.pyt	get_notesNscCs|jj|ƒdS(s7Add a new footnote to be shown up to the administrator.N(RR(RR((s=/usr/lib/python2.7/dist-packages/landscape/sysinfo/sysinfo.pytadd_footnoteRscCs|jS(s6Get all footnotes to be shown up to the administrator.(R(R((s=/usr/lib/python2.7/dist-packages/landscape/sysinfo/sysinfo.pyt
get_footnotesVscCs€g}xa|jƒD]S}y|jƒ}Wn|jtƒ|ƒqX|j|j|ƒ|j|ƒqWt|ƒj|jƒS(sÞRun all plugins, and return a deferred aggregating their results.

        This will call the run() method on each of the registered plugins,
        and return a deferred which aggregates each resulting deferred.
        (	tget_pluginstrunt_log_plugin_errorRt
addErrbackRRtaddCallbackt_report_error_note(Rt	deferredstplugintresult((s=/usr/lib/python2.7/dist-packages/landscape/sysinfo/sysinfo.pyRZscCs<t|_d|jj}tdƒ}t||d|ƒdS(Ns%s plugin raised an exception.slandscape-sysinfotlogger(tTrueR
t	__class__t__name__RR(RtfailureR%tmessageR'((s=/usr/lib/python2.7/dist-packages/landscape/sysinfo/sysinfo.pyR ks	cCsIddlm}|jrEtjj|ƒdƒ}|jd|ƒn|S(Niÿÿÿÿ(tget_landscape_log_directoryssysinfo.logsXThere were exceptions while processing one or more plugins. See %s for more information.(tlandscape.sysinfo.deploymentR-R
tostpathtjoinR(RR&R-R0((s=/usr/lib/python2.7/dist-packages/landscape/sysinfo/sysinfo.pyR#qs	(
R*t
__module__t__doc__RRRRRRRRR R#(((s=/usr/lib/python2.7/dist-packages/landscape/sysinfo/sysinfo.pyR
s									iPts   s=> c
sm|tˆƒ8}t|ƒ}d}|}	x7|D]/\}
}t|	t|
ƒt|ƒdƒ}	q/Wttjt|ƒ|	t|ƒƒƒ}x6trÃttj|t|ƒƒƒ}
g}d}xØt|ƒD]Ê}d}d}xkt|
ƒD]]}||
|}||krë||\}
}t|t|
ƒƒ}t|t|ƒƒ}qëqëW|dkrk|t|ƒ7}n|||t|ƒ7}|j	||fƒqÌW|dks²||kr¶Pn|d8}qŽWg}xët|
ƒD]Ý}ˆ}xÁt|ƒD]³}||
|}||krð||\}
}||\}}|dkrI||7}n||
|d|t|
ƒ|7}||d|
|kr£|d|t|ƒ7}q£qðqðW|j	|ƒq×W|r$|rÔ|j	dƒnˆ|}xC|D]8}|j
tj|d|ddt|ƒd	|ƒƒqåWn|r`|r@|j	dƒn|j
‡fd
†|Dƒƒndj
|ƒS(sèFormat sysinfo headers, notes and footnotes to be displayed.

    This function will format headers notes and footnotes in a way that
    looks similar to the following:

        Header1: Value1   Header3: Value3
        Header2: Value2   Header4: Value4

        => This is first note
        => This is the second note

        The first footnote.
        The second footnote.

    Header columns will be dynamically adjusted to conform to the size
    of header labels and values.
    s: iiit R4tinitial_indenttsubsequent_indenttwidthc3s|]}ˆ|VqdS(N((t.0tfootnote(tindent(s=/usr/lib/python2.7/dist-packages/landscape/sysinfo/sysinfo.pys	<genexpr>þss
(RtmintinttmathtceiltfloatR(trangetmaxRtextendttextwraptwrapR1(theaderstnotest	footnotesR8R;tcolumn_separatortnote_prefixtheaders_lentvalue_separatort
min_lengththeaderRtcolumnstheaders_per_columntheader_lengthsttotal_lengthtcolumntwidest_header_lentwidest_value_lentrowtheader_indextlinestlineR6R((R;s=/usr/lib/python2.7/dist-packages/landscape/sysinfo/sysinfo.pytformat_sysinfo{sx'		

"

 ((((RDtloggingRR>R/ttwisted.python.failureRtlandscape.lib.twisted_utilRtlandscape.lib.logRtlandscape.pluginRRRZ(((s=/usr/lib/python2.7/dist-packages/landscape/sysinfo/sysinfo.pyt<module>sn