HEX
Server: Apache
System: Linux insrv.serversdaddy.com 5.14.0-362.24.2.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Mar 30 14:11:54 EDT 2024 x86_64
User: jsaha (1066)
PHP: 8.3.6
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/cloudlinux/venv/lib64/python3.11/site-packages/cllicense/__pycache__/license.cpython-311.pyc
�

��6�u-]o�	�
�ddlmZddlmZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZddlm
Z
ddlZddlmZdd	lmZmZd
dlmZ		dde
ed
e
ede
eddfd�Zdedefd�ZGd�d��ZdS)�)�print_function)�absolute_importN)�JSONDecodeError)�Path)�run)�Optional)�CloudlinuxLicenseLib)�print_dictionary�replace_params�)�parse_cloudlinux_packages_opts�error�details�context�returnc���dtj��i}|�||d<d}nd|d<d}|�||d<|�||d<tj|tj��tj|��dS)	a�
    This function makes UI-specific JSON, prints its and exits from program. It sets "timestamp".
    And if @param error is specified, then field "result" will be filled with this parameter and exit code will be 1.
    Otherwise "result" will be filled with "success" and exit code will be 0.
    @param details: if it's specified, then field "details" will be will be filled with this parameter.
    @param context: if it's specified, then field "context" will be filled with this parameter.
    �	timestampN�resultr�successrrr)�time�json�dump�sys�stdout�exit)rrr�output�	exit_codes     �py/cllicense/license.py�_print_as_json_and_exitrs����4�9�;�;�
'�F��� ��x���	�	�$��x���	���#��y����#��y���I�f�c�j�!�!�!��H�Y�������validation_errorsc�V�d}|���D]\}}|d|�d|�d�z
}�|S)z�
    This function converts dict of validation errors in more human-readable presentation as str.
    @param validation_errors: errors
    @return:
    �z- z: �
)�items)r!r�fieldrs    r�	_beautifyr'6sM���F�)�/�/�1�1�*�*���u��)�u�)�)��)�)�)�)����Mr c�b�eZdZdZed��Zd�Zd�Zd�Zd�Z	d�Z
dd	�Zd
efd�Z
dd
�ZdS)�CloudlinuxLicensez+
    Class to check Cloudlinux license
    z%/etc/lve-utils/cloudlinux-license.inic�.�d|_i|_t��|_|j���rSt
j��}|�|j��t|dd��rdnd|_
dSd|_
dS)NF�DEFAULT�is_stagezcln-staging�cln)�_is_json�_optsr	�_license_lib�CONFIG_PATH�exists�configparser�ConfigParser�read�bool�
_subdomain)�self�configs  r�__init__zCloudlinuxLicense.__init__Is�����
���
�0�2�2�����"�"�$�$�	$�!�.�0�0�F��K�K��(�)�)�)�/3�F�9�4E�j�4Q�/R�/R�]�m�m�X]�D�O�O�O�#�D�O�O�Or c�$�d|v|_|�|��|_|jdr)|���|���n6|jdr|���n|���dS)z$
        Run command action
        z--json�set�	get_trialr)r.�_parse_argsr/�_set_run�_get_run�
_get_trial)r8�argvs  rrzCloudlinuxLicense.runUs���!�D�(��
��%�%�d�+�+��
��:�e��	��M�M�O�O�O��M�M�O�O�O�O�
�Z��
$�	��O�O������M�M�O�O�O��qr c��|j���rd}nd}dtj��|d�}t|d��dS)z#
        Run 'get' command
        �valid�invalidr)rr�licenseTN)r0�get_license_statusrr
)r8�license_status�result_datas   rr@zCloudlinuxLicense._get_runesU����/�/�1�1�	'�$�N�N�'�N�!*�����Q_�`�`����d�+�+�+�+�+r c��|jdr|j���|jd}|r|j�|��dSdS)z#
        Run 'set' command
        z--ipz--keyN)r/r0�!register_and_update_license_by_ip�"register_and_update_license_by_key)r8�keys  rr?zCloudlinuxLicense._set_runrsg���:�f��	B���?�?�A�A�A��j��!���	F���@�@��E�E�E�E�E�	F�	Fr c�~�t||j��\}}|s"|�t|����|S)z%
        Parse CLI arguments
        )r
r.�_error_and_exitr)r8rB�status�datas    rr>zCloudlinuxLicense._parse_args~sB��6�d�D�M�J�J�����	7�� � ���!5�!5�6�6�6��r rc��|jr9|�dtj��i��t|d��nu	t	t|d��|�di��z��n:#t$r-}t	dt|���d|�d���Yd}~nd}~wwxYwtj	|��dS)	z�
        Print error and exit
        :param message dict: Dictionary with keys "result" as string and optional "context" as dict
        rTrrzError: z [�]N)
r.�updaterr
�print�str�get�KeyErrorrr)r8�message�
error_code�es    rrOz!CloudlinuxLicense._error_and_exit�s���
�=�	<��N�N�K�����5�6�6�6��W�d�+�+�+�+�
<��c�'�(�+�,�,�w�{�{�9�b�/I�/I�I�J�J�J�J���
<�
<�
<���#�a�&�&�&�&�'�'�'�:�;�;�;�;�;�;�;�;�����
<�����������s�9A<�<
B3�#B.�.B3rc��	tj|jd��}|�dd��}n,#t$rtd|jd���YnwxYw	t
jd|j�d|�d�|�	��}n:#tj	$r(}td
t|�����Yd}~nd}~wwxYw	|���}n-#t$r }td|j���Yd}~nd}~wwxYwd|vr|dS|�d
��dkr&tddt|d��i���|�d
���t|d��td��dS)Nz--config�editionzCL-SolozInput config is not valid JSON.)rzhttps://z.cloudlinux.com/wapi/z/trial)rzyWe tried to get trial, but cannot connect to server application. Please, try again later or contact our support for help.z|We tried to get trial, but something was gone wrong on server side. Please, try again later or contact our support for help.rM�type�
validationzVInput data validation failed: 
 %(error_text)sPlease fix form errors and submit again.�
error_text�errors)rrYzmWe tried to get trial, but something was gone wrong. Please, try again later or contact our support for help.)r�loadsr/�poprr�requests�postr7�RequestExceptionrV�textrWr')r8r9r]�responser[�
response_jsons      r�_get_keyzCloudlinuxLicense._get_key�s2��	g��Z��
�:� 6�7�7�F��j�j��I�6�6�G�G���	g�	g�	g�#�$E�t�z�Zd�Oe�f�f�f�f�f�f�	g����	��}�%i�$�/�%i�%i�X_�%i�%i�%i�pv�w�w�w�H�H���(�	�	�	�#�K�TW�XY�TZ�TZ�
�
�
�
�
�
�
�
�
�����	����	�$�M�M�O�O�M�M���	�	�	�#�0�9A��
�
�
�
�
�
�
�
�
�����	�����M�!�!� ��'�'����V�$�$��4�4�#�;�!�)�M�(�,C�"D�"D��
�
�
�
����V�$�$�,�#�M�)�$<�=�=�=�	 �!@�	A�	A�	A�	A�	As?�58�&A!� A!�%"B�B?�B:�:B?�C�
D�"C=�=DNc
��|���}tddd|dd|j�d�gd���}|jd	kr+t	d
d�|j���d���td
dgd���}|jd	kr-t	d
d�|j���d���dSt	��dS)N�	clnreg_ksz--forcez--activationkeyz--serverUrlzhttps://xmlrpc.z.cloudlinux.com/XMLRPCT)�capture_outputrzRWe created trial but unable to register server. Please, try to run this command: `� z3` a little bit later. Contact our support for help.z/usr/bin/cldetectz--update-license)rjrr7�
returncoder�join�args)r8rMrs   rrAzCloudlinuxLicense._get_trial�s���m�m�o�o�����!�3��\�4�?�\�\�\�	
�
#�

�
�
�����!�!�#�c��h�h�v�{�+�+�c�c�c�
�
�
��)�+=�>�t�T�T�T�����!�!�#�c��h�h�v�{�+�+�c�c�c�
�
�
�
�
�

$�%�%�%�%�%r )r)rN)�__name__�
__module__�__qualname__�__doc__rr1r:rr@r?r>rOrVrjrA�r rr)r)Cs����������$�>�?�?�K�
$�
$�
$���� ,�,�,�
F�
F�
F����
�
�
�
�*A�#�*A�*A�*A�*A�X&�&�&�&�&�&r r))NNN)�
__future__rrr3rrrr�pathlibr�
subprocessr�typingrrd�	cllicenser	�	cli_utilsr
r�cl_license_arg_parser
rV�dictrr'r)rvr r�<module>rs���&�%�%�%�%�%�&�&�&�&�&�&���������
�
�
�
����� � � � � � �����������������������*�*�*�*�*�*�6�6�6�6�6�6�6�6�@�@�@�@�@�@�SW�6:���8�C�=��(�3�-��%-�d�^��?C�����4
��
�#�
�
�
�
�Y&�Y&�Y&�Y&�Y&�Y&�Y&�Y&�Y&�Y&r