AlkantarClanX12
Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/cllimits/lib/__pycache__/ |
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/cllimits/lib/__pycache__/utils.cpython-311.pyc |
� �ug� � �p � d dl Z d dlZd dlZd dlZd dlmZmZ dZd� Zd� Z d� Z dd�Zdd �Zdd�Z d� Zd � ZdS )� N)�run_command�ExternalProgramFailedzAvailable values for optionc � � | � d� � r#| � dd� � \ }}d|z d|id�S | � t � � r5| � dd� � \ }}|dz d |� � � id�S d | iS )zu Replacing params in data for show error message :param data: error's data for show message :return: z--� � z %(param)s �param)�result�context�:z: %(available_options)s�available_optionsr )� startswith�split� VALUES_STR�strip)�datar �texts �I/opt/cloudlinux/venv/lib64/python3.11/site-packages/cllimits/lib/utils.py�replace_paramsr s� � � ���t��� L��j�j��a�(�(���t�&��-�7�E�:J�K�K�K����z�"�"� A��j�j��a�(�(���e��!:�:�/������?�A� A� A� �d��� c �H � t | � � dS # t $ r Y dS w xY w)z� Checks is string contains a number (integer or float) :param s_val: String to check :return: True - string is number, False - not number TF)�float� ValueError)�s_vals r �_is_string_numberr $ s9 � �� �e�����t��� � � ��u�u����s � � !�!c �t � t | � � � � � } | � d� � rd}nV| � d� � rd}n>| � d� � rd}n&t | � � rd}| � d�} nt d� � �t d|z t | d d � � � z � � S )zs Convert value in Gbytes,Mbytes to bytes :param value: value of mem limit :return: value in bytes �kr �m� �g� zWrong memory value� N���)�str�lower�endswithr r �intr )�value�powers r �convert_mem_value_to_bytesr) 1 s� � � ��J�J�����E��~�~�c��� /���� ���� � � /���� ���� � � /���� �5� !� !� /����������-�.�.�.��t�u�}�u�U�3�B�3�Z�0�0�0�1�1�1r Tc �� � |s| S t | � � � � � } g d�}| � d� � r|d= t | � � � � � � dd� � � dd� � } | � d� � rd}| � dd� � } nd}t | � � } |D ]'}| dz dk r| dz } �| dk r|� d�} n |� | d �|� �} |S ) z� Convert memory value to adaptive value in GB, TB, etc :param value: memory value in MB or KB :param convert: if True - convert value, False - not convert :return: adaptive value in GB, TB, etc )�K�M�G�T�Pr r � r �*r! �0Kz.2f)r# r$ r% �replacer r )r'