Edit File: hardware_statistics.cpython-311.opt-1.pyc
� ����5/9eW��������������� �������������d�dl�mZmZ�d�dlmZmZmZmZmZ�d�dl Z �G�d��de ������������Zdedeeeeef���������������������������fd�Zd e defd �Zdeeeeeeeef���������f���������������������������fd�Zdeeef���������fd�ZdS�) �����)�absolute_import�division)�Optional�Dict�AnyStr�Union�ListNc�������������������������e�Zd�ZdZdS�)�NotSupportedz5 Custom error to handle compatibility issues N)�__name__� __module__�__qualname__�__doc__��������#py/clsummary/hardware_statistics.pyr���r��� ���s������������������ �Dr���r����file_content�returnc������������������p����g�}|�����������������������d������������D�]�}t������������������������}|s�|����������������������d������������D�]_}|����������������������d������������}t����������|������������dk����r5|d��������������������������������������������||d��������������������������������������������<����`|���������������������|���������������|S�)a��� Parses the response of /proc files Since this file has a possibility to include multiple objects info, we need to parse all of them in the separate dicts :file_content: /proc file content. Example: processor : 0 vendor_id : AuthenticAMD processor : 1 vendor_id : AuthenticAMD_1 return: list of dicts with each node z � �:��������r���)�split�dict�len�strip�append)r����result�info_object� temp_dict� info_attr�valuess��� r����get_proc_info_as_list_of_dictsr$������s�������$��F�#�)�)�&�1�1��!��!���F�F� ��� ��$�*�*�4�0�0�� A�� A�I��_�_�S�)�)�F��6�{�{�a���/5�a�y���/@�/@� �&��)�/�/�+�+�,��� � �i� � � � ��Mr����valuec������������������V�����t����������|������������������������������������d���������������������dz��S�)z� Helper to get numeric value of string record and convert it to mb :value: metric value from /proc file. Example: '512 KB' return: converted value. Example: 0.5 r���i���)�floatr���)r%���s��� r����convert_string_kb_to_mb_valuer(���3���s$�������������q�!�"�"�T�)�)r���c������������ �����������g�}�t����������j����������������������j��������}t����������j��������dt�����������j��������������������st����������d�������������|dvrt ����������d|��d��������������t����������dd������������5�}|�����������������������������������}ddd�������������n#�1�swxY�w�Y���t����������|������������}|D�]�}t����������|���������������������dd ������������������������|���������������������d |������������t����������|���������������������dd������������������������t����������|���������������������d d ������������������������d�}|����������������������|���������������|�S�)a_�� Prepare list of dicts with required cpu metrics The base of this method was taken from rhn_client_tools (src/up2date_client/hardware.py) Each CPU will be represented with a dict { "model": "foo", "cache_mb": 100, "frequency_mhz": 100, "id": 0 } return: list of dicts with cpu metrics z /proc/cpuinfozFile for cpuinfo is restricted!)�x86_64�i386z Machine arch z isn't compatible!�rN� processor�0z model namez cache size�0 KBzcpu MHz)�id�model�cache_mb� frequency_mhz)�os�uname�machine�access�R_OK�OSErrorr����open�readr$����int�getr(���r'���r���)�result_listr5����f�proc_cpuinfo�cpu_list�cpu�cpu_dicts��� r����get_cpu_metricsrD���=���sv�����"��K��H�J�J��E� �9�_�b�g�.�.��9��7�8�8�8��&�&�&��D�5�D�D�D�E�E�E� �o�s� #� #�� �q��v�v�x�x�� �� �� �� �� �� �� �� �� �� �� ����� �� �� �� �-�l�;�;�H��� %�� %���c�g�g�k�3�/�/�0�0���W�W�\�5�1�1�5�c�g�g�l�F�6S�6S�T�T�"�3�7�7�9�c�#:�#:�;�;� �� ��� ���8�$�$�$�$��s����0B�B�Bc�����������������������t����������j��������dt�����������j��������������������st����������d�������������t ����������dd������������5�}�|������������������������������������}ddd�������������n#�1�swxY�w�Y���t ����������|������������d���������}t����������|���������������������dd������������������������t����������|���������������������dd������������������������d �}|S�) z� Prepare dict of memory metrics Dict will be represented as: { "ram_mb": 8.5 "swap_mb": 2.04 } z /proc/meminfozFile for meminfo is restricted!r,���Nr����MemTotalr/���� SwapTotal)�ram_mb�swap_mb) r4���r7���r8���r9���r:���r;���r$���r(���r=���)r?����proc_meminfo�mem_dictr���s��� r����get_memory_metricsrL���f���s���������9�_�b�g�.�.��9��7�8�8�8� �o�s� #� #�� �q��v�v�x�x�� �� �� �� �� �� �� �� �� �� �� ����� �� �� �� ��.�l�;�;�A�>�H��0����Z��0P�0P�Q�Q�0����k�6�1R�1R�S�S����F���Ms����A � A$�'A$)� __future__r���r����typingr���r���r���r���r ���r4���� Exceptionr���r$����strr'���r(���r<���rD���rL���r���r���r����<module>rQ������sL�����1��0��0��0��0��0��0��0��6��6��6��6��6��6��6��6��6��6��6��6��6��6�� � � � � �� �� �� �� �9�� �� �� ���� �(�4����'� (�)��������>*���*���*��*��*��*�&��h�t�F�,1�&�%��2D�,E�-F��(G��H��I��&��&��&��&�R�D����/������������r���