ok
Direktori : /opt/alt/python37/lib/python3.7/site-packages/clcommon/__pycache__/ |
Current File : //opt/alt/python37/lib/python3.7/site-packages/clcommon/__pycache__/clfunc.cpython-37.pyc |
B E!wdr � @ s� d dl mZ d dl mZ d dl mZ d dlZd dlZd dlZd dlZd dlZdZ dd� Z dd d dd�Zd d� Zd ej fdd�Zd ej fdd�Zdd� Zdd� Zd*dd�Zd+dd�Zd,dd�Zdd � Zd!d"� Zd#d$� Zd%d&� Zeed'�d(d)�ZdS )-� )�absolute_import)�division)�print_functionNz/proc/lve/listc C s� y:t t��} | �d�}W dQ R X t|�dd�d �dg}W nb tk r\ dd�t�g}Y nB tk r| dd�t�g}Y n" tk r� dd �t�g}Y nX |S ) z/ Obtain lve process filesystem version � N�:� r ZOKz-clcommon: get_lve_version: Can`t open file {}z1clcommon: get_lve_version: Can`t get data from {}z*clcommon: get_lve_version: Can`t parse {}) �open�LVE_FILE�read�int�rsplit�IOError�format� IndexError� ValueError)�f�lineZlve_procfs_version� r �@/opt/alt/python37/lib/python3.7/site-packages/clcommon/clfunc.py�get_lve_version s r r i i i @)�K�M�G�Tc C sh t | �}t�d�}t�d�}t�dtj�}|�|�}|�|�}|�|�}|dks`|dks`|dkrd| S dS )zh check that val is a valid CPU limit (0-100 int or speed (% or MHZ\GHZ)) return val if ok a z^([1-9]|[1-9][0-9]|100)$z^([1-9]|[1-9][0-9]*)%$z^([1-9]|[1-9][0-9]*)(mhz|ghz)+$N)�str�re�compile� IGNORECASE�match)�val�dataZ regexp_intZ regexp_speedpZ regexp_speedfZp1Zp2Zp3r r r �validate_cpu0 s r! c C sB yt | �}W n tk r dS X || kr6|kr>n n| S dS )zH Check that val - is a string number return val as a string N)r r )r �min_val�max_valZdig_valr r r �validate_intA s r$ c C s� y`| d }|� � rd}| | } tt| d d� �t|�� d �}|| krV|kr^n n|S W n tttfk rz Y nX d S )N���r � )�isdigitr �float�BYTES_CONVERSION_TABLE�upperr r �KeyError)r r"