Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/cpapis/__pycache__/_base.cpython-39.pyc
Ðазад
a � h � @ sZ d Z ddlmZ ddlZddlZddlZddlmZm Z m Z ddlmZ G dd� d�Z dS ) �"Base class for whmapi/uapi objects� )�UnionN)�run�CalledProcessError�TimeoutExpired� )� CpAPIExecFailc @ s� e Zd ZdZed�dd�ZdZeed�dd��Zdddd �ee e edf e e df e edf e d �dd�Zee d �dd��Z dS )� CpAPIBaser ��pathc C s || _ d S )Nr )�selfr � r �;/opt/imh-python/lib/python3.9/site-packages/cpapis/_base.py�__init__ s zCpAPIBase.__init__�cpapisc C s t j�| �ot �| t j�S )z7Tests if the current user can exec a script at ``path``)�osr �isfile�access�X_OKr r r r � _can_exec s zCpAPIBase._can_execN)�user�args�timeout)�module_argsr r r �returnc C sR | j dg}|r|�d|� �� |�|� |r<|�| �|�� zt|dd|dd�}W n� ttfy� } z:tt|�j � dt |�� �||j|j|j d�|�W Y d}~nXd}~0 ty� } z8tt|�j � dt |�� �|d t |�d d�|�W Y d}~n d}~0 0 zt�|j�W S t�yL } z,td|� �||j|j|j d�|�W Y d}~n d}~0 0 dS )z�uapi/cpapi2/whmapi1 run in similar ways; this executes them Raises: CpAPIExecFail: command failed to execute or returned invalid jsonz --output=jsonz--user=Tzutf-8)�capture_output�encodingr �checkz: )�msg�cmd�stdout�stderr� returncodeN� � zInvalid JSON returned from )r �append�extend�_quote_key_valsr r r r �type�__name__�strr r! r"