관리-도구
편집 파일: stat_utils.cpython-36.pyc
3 X4sg�$ � @ s� d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZ d dlm Z d dl Z G dd� de�Zdd� Z dd � Zd d� Zdd � Zd%dd�Zd&dd�Zd'dd�Zd(dd�Zdd� Zdd� Zdd� Zd)d d!�Zd*d#d$�ZdS )+� N)�StringIO)�quotec @ s e Zd ZdS )�StatUtilsExceptionN)�__name__� __module__�__qualname__� r r �/stat_utils.pyr s r c K s� dj dd� |j� D ��}tjdj| |d��}ytjdj |��}W n, tk rl tdj| |dj |����Y nX y|d S tk r� td j|���Y nX d S )z� Perform cPanel WHM API console request and return data from result :param cmd: whm api command :return: data dict from result � c S s g | ]\}}t d j||���qS )z{0}={1})r �format)�.0�k�vr r r � <listcomp>$ s z!cpanel_whmapi.<locals>.<listcomp>z*/usr/sbin/whmapi1 {cmd} {kw} --output json)�cmd�kw� z>Failed to get JSON from this API request: {0} {1}; output: {2}�dataz,Failed to get data from this API result: {0}N) �join�items�exec_commandr �json�loads� ValueErrorr �KeyError)r �kwargs� joined_kwargs�resultZdict_resultr r r � cpanel_whmapi s r c K sn dj dd� |j� D ��}tjdj| |d��}ytjdj |��S tk rh tdj| |dj |����Y nX dS ) z� Perform Plesk php_handler utility console request and return result :param cmd: php_handler command :return: dict result r c S s g | ]\}}d j |t|���qS )z-{0} {1})r r )r r r r r r r = s z)plesk_bin_php_handler.<locals>.<listcomp>z6/usr/local/psa/bin/php_handler --{cmd} {kw} -json true)r r r zJFailed to get JSON from this API request: php_handler {0} {1}; output: {2}N)r r r r r r r r )r r r r r r r �plesk_bin_php_handler6 s r c C s� d} d}t j| �}tj|�}yJxD|D ]<}t|j|d�d�� }tdd� |j� D ��||<