관리-도구
편집 파일: utils.cpython-311.pyc
� |�Cg�+ � �x � d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlmZm Z m Z mZ d dlm Z mZ d dlmZ d dlmZmZ d dlmZ d dlmZ d dlmZ d d lmZ d d lmZ d� Z d dl m!Z! d d l"m#Z# n# e$$ r eZ!eZ#Y nw xY wdZ%dZ&dZ'dZ(ej) �* e(d� � Z+dZ,da-dZ.dZ/ G d� d� � Z0d� Z1d� Z2d5d�Z3d� Z4d� Z5d6de6d e7d!e7fd"�Z8de6d#e7d!dfd$�Z9d!e7fd%�Z:d!e7fd&�Z;d'e7d!dfd(�Z<d'e7d!dfd)�Z=d*� Z>d+� Z?d,� Z@d-� ZAd.� ZBd/� ZCd0� ZDd1� ZEd6d!ee e ee e7f f fd2�ZFd3� ZGd!ee fd4�ZHdS )7� N)�Optional�Dict�AnyStr�Union)�decode� exceptions)�DEFAULT_JWT_ES_TOKEN_PATH)� WhmApiRequest�WhmApiError)�mkdir)�process_is_running)�check_cagefs_initialized)�CL_CONFIG_FILE)�write_file_via_tempfilec � � d S )N� )�a�kws �F/opt/cloudlinux/venv/lib64/python3.11/site-packages/clsummary/utils.py�dummy_none_functionr s � ��4� ��"interpreter_versions_short_summary)�is_clpassenger_active� license_check�cl_statistics_enabled�cl_statistics_rpm_enabledz/var/lvezsummary_status.jsonz%/var/run/cloudlinux_summary.send.lockz./usr/share/cloudlinux/cl_plus/clplus_sender.pyz#/opt/cloudlinux/venv/bin/virtualenvc � � e Zd ZdZdZdZdZdS )� SummaryStatusz� Status of both, collecting and sending statistics If process still collects statistics -> IN_PROGRESS If statistics collected and sent correctly -> SUCCESS If any error during collecting or sending -> FAILED �success�in_progress�failedN)�__name__� __module__�__qualname__�__doc__�SUCCESS�IN_PROGRESS�FAILEDr r r r r 4 s) � � � � � �� � �G��K� �F�F�Fr r c �J � t j � t � � S )zS Checks is virtualenv installed :return: True/False - installed or not )�os�path�exists�ALT_PYTHON_VIRTUALENV_BINr r r �is_virtualenv_installedr/ @ s � � �7�>�>�3�4�4�4r c � � t j dt j ddddd� � } t j | t j |� � }t j d|� � d }n# t t f$ r Y dS w xY w|t j k S )a$ Check if file is locked by another process without acquiring lock. IMPORTANT! This function should NOT be used to check lock acquired by the same process that executes the is_locked() function. For example, when process executes fcntl.lockf(LOCK_FILE), and then the same process executes is_locked(LOCK_FILE), the is_locked(LOCK_FILE) call returns False. Use is_locked() function to check lock acquired by another process only. :param lock_file: file to check lock on :type lock_file: file object or descriptor �hhllhhr F) �struct�pack�fcntl�F_WRLCK�F_GETLK�unpack�OSError�IOError�F_UNLCK)� lock_file� lock_data� lock_query�lock_statuss r � is_lockedr? H s� � � ��H�e�m�Q��1�a��C�C�I���[��E�M�9�E�E� ��m�H�j�9�9�!�<�����W�� � � ��u�u����� �%�-�'�'s �;A"