%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/samba/netcmd/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/samba/netcmd/__pycache__/__init__.cpython-312.pyc

�

�I�dC6���ddlZddlZddlZddlZddlZddlZddlmZmZddlm	Z	ddl
mZddlm
Z
mZddlmZddlmZdd	lmZdd
lmZGd�de
�ZGd
�dej0�ZGd�de�ZGd�de�ZGd�de�Zy)�N)�ERR_INVALID_CREDENTIALS�LdbError)�colour)�system_session)�SambaOption�OptionError)�get_samba_logger)�SamDB�)�JSONEncoder)�ValidationErrorc�\��eZdZejdgzZejZd�Z�fd�Z�xZ	S)�Option�
validatorsc�~�t|d�xsg}|D]}	|||��y#t$r}t|��d}~wwxYw)z�Runs the list of validators on the current option.

        If the validator raises ValidationError, turn that into CommandError
        which gives nicer output.
        rN)�getattrr
�CommandError)�self�opt�valuer�	validator�es      �7/usr/lib/python3/dist-packages/samba/netcmd/__init__.py�run_validatorszOption.run_validators)sO���T�<�0�6�B�
�#�	&�I�
&��#�u�%�	&��#�
&�"�1�o�%��
&�s�	#�	<�7�<c�L��t�|�||�}|j||�|S)z�Override convert_value to run validators just after.

        This can also be done in process() but there we would have to
        replace the entire method.
        )�super�
convert_valuer)rrr�	__class__s   �rrzOption.convert_value7s+�����%�c�5�1�����C��'���)
�__name__�
__module__�__qualname__r�ATTRS�optparse�
SUPPRESS_HELPrr�
__classcell__)rs@rrr%s/��������.�E��*�*�M�&��rrc��eZdZdd�Zd�Zy)�PlainHelpFormatterc	��|j|jz
}d|jz}|jd�}|D�cgc]}tj||||����}}dj|�dz}|Scc}w)N� �
)�initial_indent�subsequent_indent)�width�current_indent�split�textwrap�fill�join)r�description�
desc_width�indent�
paragraphs�p�wrapped_paragraphs�results        r�format_descriptionz%PlainHelpFormatter.format_descriptionFs����Z�Z�$�"5�"5�5�
��t�*�*�*�� �&�&�t�,�
� �!�
�	
�M�M�!�$�)/�,2�
4�!��!����-�.��5���
��!s� A6c��|rd|zdzSy)Nr+��)r�epilogs  r�
format_epilogz PlainHelpFormatter.format_epilogSs����&�=�4�'�'�rN)r=)r r!r"r;r@r>rrr(r(Es���rr(c��eZdZdZd�Zee�Zd�Zee�Zd�Z	ee	�Z
dZgZgZ
iZdZdZdZdZdZdZdd�Zej.ej0fd	�Zdd
�Zdd�Zd�Zd
�Zd�Zdd�Zd�Z ddd�d�Z!d�Z"d�Z#dd�Z$d�Z%y)�CommandzA samba-tool command.c�Z�|jj�djd�S)Nrr+)�__doc__�
splitlines�rstrip�rs r�_get_short_descriptionzCommand._get_short_description]s%���|�|�&�&�(��+�2�2�4�8�8rc��|jjd�}|ddztjdj	|dd��zS)Nr+rr)rDr0r1�dedentr3)r�liness  r�_get_full_descriptionzCommand._get_full_descriptionbsA�����"�"�4�(���Q�x�$��������5���9�1E�!F�F�Frc�^�|jj}|jd�r|ddS|S)N�cmd_�)rr �
startswith)r�names  r�	_get_namezCommand._get_namehs-���~�~�&�&���?�?�6�"����8�O��rNFTc�*�|�||_|�||_yy�N��outf�errf�rrVrWs   r�
_set_fileszCommand._set_filess!�����D�I����D�I�rc�(�|j||�yrT)rYrXs   r�__init__zCommand.__init__�s������d�#rc�L�|j|�\}}|j�yrT)�_create_parser�print_usage)r�prog�parser�_s    r�usagez
Command.usage�s"���'�'��-�	������rc���tjd�}|�dnd|�d�}|�t|�|�d|��|j��yt|�|�d|�d|��|j��y)N�ERRORr=�(�)z: ��filez - )r�
c_DARK_RED�printrW)r�msg�evalue�klass�errs     r�_print_errorzCommand._print_error�sj������(���m��1�U�G�1����>��S�E�%���3�%�(�t�y�y�9��S�E�%���3�%�s�6�(�3�$�)�)�Drc�t�|j�}|j|�}t||t|�|��S)z:Helper to connect to Ldb database using command line opts.)�credentials�session_info�lp)�get_loadparm�get_credentialsr
r)r�ldap_url�	sambaopts�credoptsrs�credss      r�ldb_connectzCommand.ldb_connect�s;��
�
#�
#�
%���(�(��,���X�5�"0��"4��=�	=rc��tj||jtdd��|jj	d�y)z�Print json on the screen using consistent formatting and sorting.

        A custom JSONEncoder class is used to help with serializing unknown
        objects such as Dn for example.
        �T)�clsr6�	sort_keysr+N)�json�dumprVr�write)r�datas  r�
print_jsonzCommand.print_json�s,��	
�	�	�$��	�	�{�1��M��	�	����rc��t|t�r+|j\}}}|j}|j}d}ntj�\}}}|}d}d}t|t�r+t||j��|j�d}�n=t|t�r�|j\}}	|tk(rtd|j��d}n�|	dk(rtd|j��d}n�|	jd�r|j||	d	�d}n�|j||	d	�n�t|t �r|j|d
��d}n{t|t"�r|j||d�nWt%|�t&ur|j||d
�d}n0|�|j|�n|j||t)|��|st+j,�dk\r"t/j0||j��yy)zdisplay a command errorFzuncaught exceptionTrgzInvalid username or passwordz9LDAP client internal error: NT_STATUS_NETWORK_UNREACHABLEzCould not reach remote serverzUnable to open tdb �ldb�assert)rm�runtime�	exceptionN�)�
isinstancer�exception_info�inner_exception�message�sys�exc_inforrjrWrbr�argsrrPro�AssertionError�RuntimeError�type�	Exception�str�samba�get_debug_level�	traceback�print_tb)
rr�etyperl�
etracebackr�r��force_traceback�	ldb_ecode�ldb_emsgs
          r�show_command_errorzCommand.show_command_error�s����a��&�*+�*:�*:�'�U�F�J��/�/�O��i�i�G�#�O�*-�,�,�.�'�U�F�J��O�*�G�"�O��a��%��&�t�y�y�)��J�J�L�#�O�
���
2�$3�$8�$8�!�Y���3�3��4�4�9�9�E�"'���X�X��5�D�I�I�F�"'���$�$�%:�;��!�!�'�8�U�;�"'���!�!�'�8�U�;�
���
8����g�X��6�"�O�
���
6����g�v�y�9�
�/�
"�i�
/����g�v�{�;�"�O�
�
$����g�&����g�v�s�5�z�:��e�3�3�5��:����z��	�	�:�;rc��tj|j|jt	�||��}|j|j�i}t|jj��D]0}|j|}||�||<|j||��2|jr|jdddd��||fS)N)rbr4�	formatterr_r?z--colorz'use colour if available (default: auto)zalways|never|auto�auto)�help�metavar�default)
r$�OptionParser�synopsis�full_descriptionr(�add_options�
takes_options�sorted�takes_optiongroups�keys�add_option_group�
use_colour�
add_option)rr_r?r`�optiongroupsrQ�optiongroups       rr]zCommand._create_parser�s����&�&��-�-��-�-�(�*��f�	&��
	���4�-�-�.����4�2�2�7�7�9�:�	8�D��1�1�$�7�K�!,�V�!4�L����#�#�L��$6�7�	8��?�?����i�#L�&9�&,�
�
.�
�|�#�#rc�@�|jj|dz�y)Nr+)rVr�)r�texts  rr�zCommand.message�s���	�	����t��$rrUc�<�|j||�||_||fS)z8This is a leaf node, the command that will actually run.)rY�command_name)r�pathrVrW�argvs     r�_resolvezCommand._resolve�s"������d�#� ����d�|�rc�D�|j|j�\}}|jt|��\}}t	|j
�}|jD]-}|jD]}|j��||j=��/|j|�|jr!|j|jdd��d}	d}
d}t|j�D]2\}}
|
ddk7r
|
ddk7r|	dz
}	|
dd	k(s|
ddk(rd
}�.|
dz
}
�4t|�|	ks|st|�|
kDr|j!�yt|�|_||_||_	|j(|i|��S#t*$r}|j-|�Yd}~yd}~wwxYw)N�colorr�rF����?�*r�+T)r]r��
parse_args�list�dict�__dict__�
option_groups�option_list�dest�updater��apply_colour_choice�pop�	enumerate�
takes_args�lenr^�raw_argv�raw_args�
raw_kwargs�runr�r�)rr�r`r��optsr��kwargs�option_group�option�min_args�max_args�undetermined_max_args�i�argrs               r�_runzCommand._run�s���#�2�2�4�3D�3D�E�����&�&�t�D�z�2�
��d��d�m�m�$��"�0�0�	,�L�&�2�2�
,���;�;�*��v�{�{�+�
,�	,�	�
�
�l�#��?�?��$�$�V�Z�Z���%@�A����� %������0�	�F�A�s��2�w�#�~�#�b�'�S�.��A�
���2�w�#�~��R��C��(,�%��A�
��
	�
��I�� �*?�C��I�PX�DX���� ���T�
��
���
� ���	��4�8�8�T�,�V�,�,���	��#�#�A�&���	�s�)E;�;	F�F�Fc�4�td|j�d���)z=Run the command. This should be overridden by all subclasses.�'z' run method not implemented)�NotImplementedErrorr�)rr�r�s   rr�zCommand.runs��!�A�d�&7�&7�%8�8T�"U�V�Vrc�R�td|xs|j|j||d�|��S)zGet a logger object.)rQ�stream�verbose�quietr>)r	rQrW)rrQr�r�r�s     r�
get_loggerzCommand.get_logger s5�����"����4�9�9��5����	rc��||_	tj|j|j|��y#t
$r}t
d|�d���d}~wwxYw)z�Heuristics to work out whether the user wants colour output, from a
        --color=yes|no|auto option. This alters the ANSI 16 bit colour
        "constants" in the colour module to be either real colours or empty
        strings.
        )�hintzUnknown --color option: z% please choose from always|never|autoN)�requested_colourr�colour_if_wantedrVrW�
ValueErrorr)r�	requestedrs   rr�zCommand.apply_colour_choice'sg��!*���	G��#�#�D�I�I�$(�I�I�)2�
4���	G��!9�)��EF� F�G�
G��	G�s�,6�	A�A�A)NNrT)r=FF)&r r!r"rDrH�property�short_descriptionrLr�rRrQr�r�r�r��hiddenr�r�r�r�r�rYr��stdout�stderrr[rbrorzr�r�r]r�r�r�r�r�r�r>rrrBrBZs����9�!�!7�8��G� � 5�6����I��D��H��J��M���
�F��J����H��H��J�� �J�J�S�Z�Z�$��E�=��.;�`$�(%�*.�D��(�TW��
GrrBc�,�eZdZdZdZiZddd�d�Zd�Zy)�SuperCommandz&A samba-tool command with subcommands.z%prog <subcommand>NrUc��||_|j||�g}t|�D]�\}}||jvrC||dzdt	|�z}|�d|��}	|j|}
|
j
|	g|��||d��cS|dvr|dk(rd}|j
|��tt|�d|�d	�|j�
�|gfcStd|z|j�
�||fS)aThis is an internal node. We need to consume one of the args and
        find the relevant child, returning an instance of that Command.

        If there are no children, this SuperCommand will be returned
        and its _run() will do a --help like thing.
        rNr*rU)�--helpr�Nz-hz-Vz	--versionr�r�z: no such subcommand: r+rgz%s: missing subcommand
)	r�rYr��subcommands�tupler��appendrjrV)rr�rVrWr��
deferred_argsr��a�sub_args�sub_path�subs           rr�zSuperCommand._resolve>s��!�������d�#�
�
��d�O�	�D�A�q��D�$�$�$���A���<�%�
�*>�>��"�V�1�Q�C�=���&�&�q�)��#�s�|�|�H�N�x�N�d��N�N��I�I���;� �A��$�$�Q�'��
�D�!�<�4�9�9�M��"�:��#	�(	�(�D�1��	�	�B��m�$�$rc���d}t|jj��}t|D�cgc]
}t	|���c}�}|D]4}|j|}|j
r�|d|||jfzz
}�6|d|j�d�z
}|j|j|��\}}	|jt|��\}
}|j�ycc}w)Nz
Available subcommands:
z  %*s  - %s
z5For more help on a specific subcommand, please type: z <subcommand> (-h|--help)
)r?r�)r�r�r��maxr�r�r�r�r]r�r��
print_help)rr�r?�subcmds�c�
max_length�cmd_name�cmdr`r�r�r�s            rr�zSuperCommand._runds���-����)�)�.�.�0�1���'�2�Q�#�a�&�2�3�
��	>�H��"�"�8�,�C��z�z���o���X�s�'<�'<�)>�>�
>�F�		>�	�J��'�'�(�(C�E�	F�� $�2�2�4�3D�3D�V�2�T�����&�&�t�D�z�2�
��d�
	������%3s�C")r r!r"rDr�r�r�r�r>rrr�r�7s��0�#�H��K�)-�D�$%�Lrr�c��eZdZdZdd�Zd�Zy)rz1An exception class for samba-tool Command errors.Nc�R�||_||_tj�|_yrT)r�r�r�r�r�)rr�r�s   rr[zCommandError.__init__�s�����.���!�l�l�n��rc� �d|jzS)NzCommandError(%s))r�rGs r�__repr__zCommandError.__repr__�s��!�D�L�L�0�0rrT)r r!r"rDr[rr>rrrr}s��;�-�
1rr)rr$r�r1r�r�r�rrr�
samba.authr�samba.getoptrr�samba.loggerr	�samba.samdbr
�encodersrrr
r�IndentedHelpFormatterr(�objectrBr�r�rr>rr�<module>r
s|��&��
����1��%�1�)��!�'��[��@��7�7��*ZG�f�ZG�zC�7�C�L	1�9�	1r

Zerion Mini Shell 1.0