Edit File: license.cpython-311.opt-1.pyc
� ����5/9e���������������� �������� ����d�dl�mZ�d�dl�mZ�d�dlZd�dlZd�dlZd�dlZd�dlmZ�d�dlm Z �d�dl mZ�d�dlm Z �d�dlZd�dlmZ�d�d lmZmZ�d dlmZ� � �dde e���������d e e���������de e���������ddfd�Zdedefd�Z�G�d��d������������ZdS�)�����)�print_function)�absolute_importN)�JSONDecodeError)�Path)�run)�Optional)�CloudlinuxLicenseLib)�print_dictionary�replace_params����)�parse_cloudlinux_packages_opts�error�details�context�returnc������������������������dt����������j�����������������������i}|��|�|d<���d}nd|d<���d}|�||d<���|�||d<���t����������j��������|t����������j���������������������t����������j��������|�������������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����successr���r���r���)�time�json�dump�sys�stdout�exit)r���r���r����output� exit_codes��� �py/cllicense/license.py�_print_as_json_and_exitr������s���������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����fieldr���s��� r���� _beautifyr'���6���sM��������F�)�/�/�1�1��*��*���u��)�u�)�)��)�)�)�)����Mr ���c��������������������b�����e�Zd�ZdZ�ed������������Zd��Zd��Zd��Zd��Z d��Z dd �Zd efd�Z dd �ZdS�)�CloudlinuxLicensez+ Class to check Cloudlinux license z%/etc/lve-utils/cloudlinux-license.inic������������������.����d|�_���������i�|�_��������t������������������������|�_��������|�j�������������������������������������������rSt ����������j����������������������}|���������������������|�j���������������������t����������|d���������d���������������������rdnd|�_ ��������d�S�d|�_ ��������d�S�)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__I���s��������� ��� �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�|�_���������|����������������������|������������|�_��������|�j��������d���������r)|�������������������������������������|�������������������������������������n6|�j��������d���������r|�������������������������������������n|�������������������������������������dS�)z$ Run command action z--json�set� get_trialr���)r.����_parse_argsr/����_set_run�_get_run� _get_trial)r8����argvs��� r���r���zCloudlinuxLicense.runU���s��������!�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}dt����������j����������������������|d�}t����������|d�������������dS�)z# Run 'get' command �valid�invalidr���)r���r����licenseTN)r0����get_license_statusr���r ���)r8����license_status�result_datas��� r���r@���zCloudlinuxLicense._get_rune���sU���������/�/�1�1�� '�$�N�N��'�N�!*�����Q_�`�`����d�+�+�+�+�+r ���c�����������������������|�j���������d���������r|�j��������������������������������������������|�j���������d���������}|r|�j�����������������������������|�������������dS�dS�)z# Run 'set' command z--ipz--keyN)r/���r0����!register_and_update_license_by_ip�"register_and_update_license_by_key)r8����keys��� r���r?���zCloudlinuxLicense._set_runr���sg��������:�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���)r8���rB����status�datas��� r���r>���zCloudlinuxLicense._parse_args~���sB�������6�d�D�M�J�J������ 7�� � ���!5�!5�6�6�6��r ���r���c����������������������|�j���������r9|���������������������dt����������j����������������������i�������������t����������|d�������������nu �t ����������t����������|d���������������������|���������������������di�������������z���������������n:#�t����������$�r-}t ����������dt����������|�������������d|�d��������������Y�d}~nd}~ww�xY�wt����������j ��������|�������������dS�) z� Print error and exit :param message dict: Dictionary with keys "result" as string and optional "context" as dict r���Tr���r���zError: z [�]N) r.����updater���r ����print�str�get�KeyErrorr���r���)r8����message� error_code�es��� r���rO���z!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.�.B3r���c����������������������� �t����������j��������|�j��������d���������������������}n,#�t����������$�r�t ����������d|�j��������d�����������������������Y�nw�xY�w �t����������j��������d|�j����������d�|�������������}n:#�t ����������j��������$�r(}t ����������dt����������|��������������������������Y�d�}~nd�}~ww�xY�w �|������������������������������������}n-#�t����������$�r }t ����������d|j ����������������������Y�d�}~nd�}~ww�xY�wd |v�r|d ���������S�|���������������������d ������������dk����r&t ����������dd t����������|d���������������������i��������������|���������������������d �������������t ����������|d����������������������t ����������d�������������d�S�)Nz--configzInput config is not valid JSON.)r���zhttp://z".cloudlinux.com/wapi/CL-Solo/trial)r���zyWe 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)r���rY���zmWe tried to get trial, but something was gone wrong. Please, try again later or contact our support for help.) r����loadsr/���r���r����requests�postr7����RequestExceptionrV����textrW���r'���)r8���r9����responser[���� response_jsons��� r����_get_keyzCloudlinuxLicense._get_key����s����� g��Z�� �:� 6�7�7�F�F���� g�� g�� g�#�$E�t�z�Zd�Oe�f�f�f�f�f�f� g���� ��}�%f���%f�%f�%f�ms�t�t�t�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?����"��&A� A�A/��/B&�>B!�!B&�*B?��? C)� C$�$C)Nc����������� �����������|�������������������������������������}t����������ddd|dd|�j����������d�gd�������������}|j��������d k����r+t ����������d d���������������������|j����������������������d��������������t����������d dgd�������������}|j��������d k����r-t ����������d d���������������������|j����������������������d��������������d�S�t �������������������������d�S�)N� clnreg_ksz--forcez--activationkeyz--serverUrlzhttps://xmlrpc.z.cloudlinux.com/XMLRPCT)�capture_outputr���zRWe 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)rh���r���r7���� returncoder����join�args)r8���rM���r���s��� r���rA���zCloudlinuxLicense._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���)r���N)�__name__� __module__�__qualname__�__doc__r���r1���r:���r���r@���r?���r>���rO���rV���rh���rA�����r ���r���r)���r)���C���s��������������������$�>�?�?�K� $�� $�� $������ ,��,��,� F�� F�� F������ �� �� �� �)A�#��)A��)A��)A��)A�V&��&��&��&��&��&r ���r)���)NNN)� __future__r���r���r3���r���r���r���r����pathlibr���� subprocessr����typingr���rb���� cllicenser ���� cli_utilsr ���r����cl_license_arg_parser ���rV����dictr���r'���r)���rt���r ���r����<module>r}������s������&��%��%��%��%��%��&��&��&��&��&��&��������������� � � � ������� �� �� �� �� �� �������������������������������������������*��*��*��*��*��*��6��6��6��6��6��6��6��6��@��@��@��@��@��@��SW�6:����8�C�=���(�3�-���%-�d�^��?C��������4 ��� �#�� �� �� �� �X&��X&��X&��X&��X&��X&��X&��X&��X&��X&r ���