403Webshell
Server IP : 50.21.180.56  /  Your IP : 216.73.216.224
Web Server : Apache
System : Linux info 3.0 #1337 SMP Tue Jan 01 00:00:00 CEST 2000 all GNU/Linux
User : ws67922704 ( 67922704)
PHP Version : 8.5.13
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /kunden/lib/python3/dist-packages/breezy/bzr/smart/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /kunden/lib/python3/dist-packages/breezy/bzr/smart/__pycache__/medium.cpython-313.pyc
�

p��g�����SrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKJr \"\	"5S5 SSK
JrJr \Rr"SS\R5rS	rS
r"SS5r\R(4r\R,S
:XaSr\\4-
r"SS\5r"SS\5r"SS\5r"SS5r"SS5r"SS5rSqSq"SS\5r "SS\ 5r!"SS \!5r""S!S"5r#"S#S$\!5r$Sr%S%r&"S&S'\!5r'"S(S)\'5r("S*S+\'5r)"S,S-\RT5r+"S.S/\5r,g)0asThe 'medium' layer for the smart servers and clients.

"Medium" here is the noun meaning "a means of transmission", not the adjective
for "the quality between big and small."

Media carry the bytes of the requests somehow (e.g. via TCP, wrapped in HTTP, or
over SSH), and pass them to and from the protocol logic.  See the overview in
breezy/transport/smart/__init__.py.
�N�)�lazy_importa	
import select
import socket
import weakref

from breezy import (
    debug,
    trace,
    transport,
    ui,
    urlutils,
    )
from breezy.i18n import gettext
from breezy.bzr.smart import client, protocol, request, signals, vfs
from breezy.transport import ssh
)�errors�osutilsc��\rSrSrSrSrSrg)�HpssVfsRequestNotAllowed�Bz[VFS requests over the smart server are not allowed. Encountered: %(method)s, %(arguments)s.c��XlX lg�N)�method�	arguments)�selfrr
s   �9/usr/lib/python3/dist-packages/breezy/bzr/smart/medium.py�__init__�!HpssVfsRequestNotAllowed.__init__Hs����"��)r
rN��__name__�
__module__�__qualname__�__firstlineno__�_fmtr�__static_attributes__�rrrrBs��	%�	�
#rrc�t�UR[R5(a/[RnU[	[R5SnX4$UR[R
5(a/[RnU[	[R
5SnX4$[RnX4$)abDetermine the right protocol factory for 'bytes'.

This will return an appropriate protocol factory depending on the version
of the protocol being used, as determined by inspecting the given bytes.
The bytes should have at least one newline byte (i.e. be a whole line),
otherwise it's possible that a request will be incorrectly identified as
version 1.

Typical use would be::

     factory, unused_bytes = _get_protocol_factory_for_bytes(bytes)
     server_protocol = factory(transport, write_func, root_client_path)
     server_protocol.accept_bytes(unused_bytes)

:param bytes: a str of bytes of the start of the request.
:returns: 2-tuple of (protocol_factory, unused_bytes).  protocol_factory is
    a callable that takes three args: transport, write_func,
    root_client_path.  unused_bytes are any bytes that were not part of a
    protocol version marker.
N)�
startswith�protocol�MESSAGE_VERSION_THREE�build_server_protocol_three�len�REQUEST_VERSION_TWO�SmartServerRequestProtocolTwo�SmartServerRequestProtocolOne)�bytes�protocol_factorys  r�_get_protocol_factory_for_bytesr&Ms���*
����6�6�7�7�#�?�?���c�(�8�8�9�;�<���"�"�
�	�	�(�6�6�	7�	7�#�A�A���c�(�6�6�7�9�:���"�"�$�A�A���"�"rc��SnSnUS:Xa/U"S5nX#-
nUS:XaUS4$URS5nUS:XaM/USUS-nX!S-SnXE4$)z�Read bytes using read_bytes_func until a newline byte.

This isn't particularly efficient, so should only be used when the
expected size of the line is quite short.

:returns: a tuple of two strs: (line, excess)
���r��
N)�find)�read_bytes_func�newline_posr$�	new_bytes�line�excesss      r�	_get_liner1ms|���K��E�
��
�#�A�&�	�
�������#�:���j�j��'��
��
��"�;��?�#�D�
��?�$�
%�F��<�rc�B�\rSrSrSrSrSrSrSrSr	Sr
S	rS
rg)�SmartMedium�zBBase class for smart protocol media, both client- and server-side.c��SUlgr��_push_back_buffer�rs rr�SmartMedium.__init__�s
��!%��rc��[U[5(d[U5eURb$[	SRUR55eUS:XagXlg)z�Return unused bytes to the medium, because they belong to the next
request(s).

This sets the _push_back_buffer to the given bytes.
Nz5_push_back called when self._push_back_buffer is {!r}r)�
isinstancer$�	TypeErrorr7�AssertionError�format)r�datas  r�
_push_back�SmartMedium._push_back�s]���$��&�&��D�/�!��!�!�-� �G�N�N��*�*���
�
�3�;��!%�rc��URS:Xa[SRU55eURnSUlU$)NrzU{}._push_back_buffer should never be the empty string, which can be confused with EOF)r7r=r>�rr$s  r�_get_push_back_buffer�!SmartMedium._get_push_back_buffer�sE���!�!�S�(� �1�17�����
��&�&��!%����rc�~�URbUR5$[U[5nUR	U5$)z�Read some bytes from this medium.

:returns: some bytes, possibly more or less than the number requested
    in 'desired_count' depending on the medium.
)r7rD�min�_MAX_READ_SIZE�_read_bytes)r�
desired_count�
bytes_to_reads   r�
read_bytes�SmartMedium.read_bytes�s<���!�!�-��-�-�/�/��M�>�:�
����
�.�.rc�,�[UR5er��NotImplementedErrorrI�r�counts  rrI�SmartMedium._read_bytes�s��!�$�"2�"2�3�3rc�V�[UR5upURU5 U$)z�Read bytes from this request's response until a newline byte.

This isn't particularly efficient, so should only be used when the
expected size of the line is quite short.

:returns: a string of bytes ending in a newline (byte 0x0A).
)r1rLr@)rr/r0s   rr1�SmartMedium._get_line�s%��!����1���������rc�D�[RRXU5 g)a"Notify that this medium has activity.

Implementations should call this from all methods that actually do IO.
Be careful that it's not called twice, if one method is implemented on
top of another.

:param bytes: Number of bytes read or written.
:param direction: 'read' or 'write' or None.
N)�ui�
ui_factory�report_transport_activity)rr$�	directions   r�_report_activity�SmartMedium._report_activity�s��	�
�
�/�/��Y�Grr6N)
rrrr�__doc__rr@rDrLrIr1r[rrrrr3r3�s)��L�&�&�$�	/�4�
�
Hrr3�win32i6'c�p�\rSrSrSr\R
rSSjrSrSr	Sr
SrS	rS
r
SrSrS
rSrg)�SmartServerStreamMedium��a�Handles smart commands coming over a stream.

The stream may be a pipe connected to sshd, or a tcp socket, or an
in-process fifo for testing.

One instance is created for each connected client; it can serve multiple
requests in the lifetime of the connection.

The server passes requests through to an underlying backing transport,
which will typically be a LocalTransport looking at the server's filesystem.

:ivar _push_back_buffer: a str of bytes that have been read from the stream
    but not used yet, or None if there are no buffered bytes.  Subclasses
    should make sure to exhaust this buffer before reading more bytes from
    the stream.  See also the _push_back method.
Nc��XlX lSUlUc[S5eX0l[US-S5Ul[RU5 g)zUConstruct new server.

:param backing_transport: Transport for the directory served.
FNzYou must supply a timeout.g$@g�?)	�backing_transport�root_client_path�finishedr=�_client_timeoutrG�_client_poll_timeoutr3r)rrcrd�timeouts    rr� SmartServerStreamMedium.__init__�sO��"3�� 0����
��?� �!=�>�>�&��$'��$���$<��!����T�"rc���SSKJn UR(d4UR5nUR	U5 UR(dM4UR5 g![
RaRn[RSRU55 [R5 UR5 SnAgSnAf[a&nURSRX55 eSnAff=f)z,Serve requests until the client disconnects.r)�stderrz{}Nz{} terminating on exception {}
)�sysrkre�_build_protocol�_serve_one_requestr�ConnectionTimeout�trace�noter>�log_exception_quietly�_disconnect_client�	Exception�write)rrk�server_protocol�es    r�serve�SmartServerStreamMedium.serve�s���	�	��m�m�"&�"6�"6�"8���'�'��8��m�m�m�	
���!���'�'�	��J�J�t�{�{�1�~�&��'�'�)��#�#�%����	��L�L�;�B�B�4�K�L���	�s%�AA�C2�2AB?�?
C2�!C-�-C2c�Z�[RSRU55 SUlg)z3When we finish this message, stop looking for more.zStopping {}TN)rp�mutterr>rer8s r�_stop_gracefully�(SmartServerStreamMedium._stop_gracefullys ��
���]�)�)�$�/�0���
rc��g�z>Close the current connection. We stopped due to a timeout/etc.Nrr8s rrs�*SmartServerStreamMedium._disconnect_client��rc�,�[UR5e)aYWait for more bytes to be read, but timeout if none available.

This allows us to detect idle connections, and stop trying to read from
them, without setting the socket itself to non-blocking. This also
allows us to specify when we watch for idle timeouts.

:return: Did we timeout? (True if we timed out, False if there is data
    to be read)
)rP�_wait_for_bytes_with_timeout�r�timeout_secondss  rr��4SmartServerStreamMedium._wait_for_bytes_with_timeouts��"�$�"C�"C�D�Drc��URUR5 UR(agUR5n[	U5up#U"UR
URUR5nURU5 U$)aIdentifies the version of the incoming request, and returns an
a protocol object that can interpret it.

If more bytes than the version prefix of the request are read, they will
be fed into the protocol before it is returned.

:returns: a SmartServerRequestProtocol.
N)	r�rfrer1r&rc�
_write_outrd�accept_bytes)rr$r%�unused_bytesrs     rrm�'SmartServerStreamMedium._build_protocol#sr��	
�)�)�$�*>�*>�?��=�=����� ��)H��)O�&��#��"�"�D�O�O�T�5J�5J�
��	���l�+��rc��UR5U-n[X R5nS=pVU(doU(dhUR5U:aTUR(ag[R	U//U/U5upWnU(dU(dUR5U:aMTU(dU(ag[R"SRU55e![
a]n[
USS5n	U	c[
USS5bURSn	U	[;aSnAgU	[R:XaSnAGMeSnAf[a gf=f)z�select() on a file descriptor, waiting for nonblocking read().

This will raise a ConnectionTimeout exception if we do not get a
readable handle before timeout_seconds.
:return: None
N�errno�argsrz)disconnecting client after {:.1f} seconds)�_timerrGrgre�select�OSError�getattrr��_bad_file_descriptorr��EINTR�
ValueErrorrror>)
r�fdr��t_end�poll_timeout�rs�xs�_rw�errs
          r�_wait_on_descriptor�+SmartServerStreamMedium._wait_on_descriptor8s�����
��/���?�,E�,E�F������R�D�K�K�M�E�$9��}�}��
�"�M�M�2�$��R�D�,�G�	��r�	�R�D�K�K�M�E�$9�$����&�&�7�>�>��O�
�	
���

��a��$�/���;�7�1�f�d�#;�#G��&�&��)�C��.�.���E�K�K�'�����
��
�s*�!C�
E� 7D8�D8�7D8�8
E�Ec��UcgURU5 g![a e[a UR5 gf=f)zlRead one request from input, process, send back a response.

:param protocol: a SmartServerRequestProtocol.
N)�_serve_one_request_unguarded�KeyboardInterruptrt�terminate_due_to_error)rrs  rrn�*SmartServerStreamMedium._serve_one_requestZsF��
���	*��-�-�h�7�� �	���	*��'�'�)�	*�s��$?�?c�,�[UR5e)z<Called when an unhandled exception from the protocol occurs.)rPr�r8s rr��.SmartServerStreamMedium.terminate_due_to_errorhs��!�$�"=�"=�>�>rc�,�[UR5e)zXGet some bytes from the medium.

:param desired_count: number of bytes we want to read.
rO�rrJs  rrI�#SmartServerStreamMedium._read_bytesls��
"�$�"2�"2�3�3r)rgrfrcrerd��/N)rrrrr]�timer�rrxr|rsr�rmr�rnr�rIrrrrr`r`�sG���"�Y�Y�F�
#�"�*�
M�
E��* 
�D*�?�4rr`c�N�\rSrSrS
SjrSrSrSrSrSr	S	r
S
rSrSr
g)�SmartServerSocketStreamMediumitNc��[RXX4S9 URS5 XlUR	5Ulg![a
 SUlgf=f)ziConstructor.

:param sock: the socket the server will read from.  It will be put
    into blocking mode.
)rdrhTz	<unknown>N)r`r�setblocking�socket�getpeername�_client_infor�)r�sockrcrdrhs     rr�&SmartServerSocketStreamMedium.__init__us_��	 �(�(��6F�	)�	
�	
�������	,� $� 0� 0� 2�D����	,� +�D��	,�s�A�A�Ac�b�SRURRUR5$)Nz
{}(client={}))r>�	__class__rr�r8s r�__str__�%SmartServerSocketStreamMedium.__str__�s%���%�%�d�n�n�&=�&=�t�?P�?P�Q�Qrc�x�SRURURRUR5$)Nz{}.{}(client={}))r>rr�rr�r8s r�__repr__�&SmartServerSocketStreamMedium.__repr__�s0��!�(�(��O�O�T�^�^�4�4�d�6G�6G�
�	
rc��UR5(aUUR[R5nUS:XaSUlgURU5 UR5(aMUUR
UR5 g)NrT)�next_read_sizerLr�MAX_SOCKET_CHUNKrer�r@�unused_data)rrr$s   rr��:SmartServerSocketStreamMedium._serve_one_request_unguarded�sk���%�%�'�'��O�O�G�$<�$<�=�E���|� $��
���!�!�%�(��%�%�'�'�	
����,�,�-rc�8�URR5 gr)r��closer8s rrs�0SmartServerSocketStreamMedium._disconnect_client�s�������rc�:�URURU5$)�`Wait for more bytes to be read, but timeout if none available.

This allows us to detect idle connections, and stop trying to read from
them, without setting the socket itself to non-blocking. This also
allows us to specify when we watch for idle timeouts.

:return: None, this will raise ConnectionTimeout if we time out before
    data is available.
)r�r�r�s  rr��:SmartServerSocketStreamMedium._wait_for_bytes_with_timeout�s���'�'����_�E�Erc�X�[R"URUR5$r)r�read_bytes_from_socketr�r[r�s  rrI�)SmartServerSocketStreamMedium._read_bytes�s���-�-�d�k�k�4�;P�;P�Q�Qrc�F�URR5 SUlg�NT)r�r�rer8s rr��4SmartServerSocketStreamMedium.terminate_due_to_error�s��	
��������
rc�H�[R"5n[R"URXR5 S[
R;aN[R"5n[RSSU[U5[R"5U-
5 gg)N�hpssz*%12s: [%s] %d bytes to the socket in %.3fs�wrote)r�perf_counter�send_allr�r[�debug�debug_flags�_thread�	get_identrpr{r )rr$�tstart�	thread_ids    rr��(SmartServerSocketStreamMedium._write_out�sx���%�%�'��������e�-B�-B�C��U�&�&�&��)�)�+�I��L�L�<����E�
��$�$�&��/�
�'r)r�rer�r�)rrrrrr�r�r�rsr�rIr�r�rrrrr�r�ts2��,�"R�
�
.��
F�R��rr�c�V^�\rSrSrSSjrU4SjrSrSrSrSr	Sr
S	rS
rU=r
$)�SmartServerPipeStreamMediumi�c��[RXUS9 [RS:XaISSKnX4H>n[USS5nU(dMUR
U"5[R5 M@ Xl	X l
g)z�Construct new server.

:param in_file: Python file from which requests can be read.
:param out_file: Python file to write responses.
:param backing_transport: Transport for the directory served.
)rhr^rN�fileno)r`rrl�platform�msvcrtr��setmode�os�O_BINARY�_in�_out)r�in_file�out_filercrhr��fr�s        rr�$SmartServerPipeStreamMedium.__init__�sf��	 �(�(��'�(�R��<�<�7�"���(�� ��H�d�3���6��N�N�6�8�R�[�[�9�)����	rc�>�URn[R[U5U5 [TU]5[R
[U55 $![R
[U55 f=f)z"See SmartServerStreamMedium.serve.)r|�signals�register_on_hangup�id�superrx�unregister_on_hangup)r�stop_gracefullyr�s  �rrx�!SmartServerPipeStreamMedium.serve�sW����/�/���"�"�2�d�8�_�=�	3��7�=�?��(�(��D��2��G�(�(��D��2�s�
A� A:c��UR5nUS:XaURR5 gURU5nUS:Xa"SUlURR5 gURU5 M})NTrr)r�r��flushrLrer�)rrrKr$s    rr��8SmartServerPipeStreamMedium._serve_one_request_unguarded�sn���%�3�3�5�M���!��	�	���!���O�O�M�2�E���|� $��
��	�	���!���!�!�%�(�rc��URR5 URR5 URR5 gr)r�r�r�r�r8s rrs�.SmartServerPipeStreamMedium._disconnect_client�s,���������	�	�����	�	���rc���[URSS5b[RS:XagUR	URU5$![
Ra gf=f)r�r�Nr^)r�r�rlr�r��io�UnsupportedOperationr�s  rr��8SmartServerPipeStreamMedium._wait_for_bytes_with_timeout�sY���4�8�8�X�t�,�4�����8O��	��+�+�D�H�H�o�F�F���&�&�	��	�s�A�A"�!A"c�8�URRU5$r)r��readr�s  rrI�'SmartServerPipeStreamMedium._read_bytes
s���x�x�}�}�]�+�+rc�F�URR5 SUlgr�)r�r�rer8s rr��2SmartServerPipeStreamMedium.terminate_due_to_error
s��	
�	�	������
rc�:�URRU5 gr)r�rurCs  rr��&SmartServerPipeStreamMedium._write_outs���	�	����r)r�r�rer)rrrrrrxr�rsr�rIr�r�r�
__classcell__�r�s@rr�r��s0����&	3�)�$�
�$,���rr�c�Z�\rSrSrSrSrSrSrSrSr	Sr
S	rS
rSr
SrS
rSrg)�SmartClientMediumRequestiaA request on a SmartClientMedium.

Each request allows bytes to be provided to it via accept_bytes, and then
the response bytes to be read via read_bytes.

For instance:
request.accept_bytes('123')
request.finished_writing()
result = request.read_bytes(3)
request.finished_reading()

It is up to the individual SmartClientMedium whether multiple concurrent
requests can exist. See SmartClientMedium.get_request to obtain instances
of SmartClientMediumRequest, and the concrete Medium you are using for
details on concurrency and pipelining.
c��XlSUlg)z;Construct a SmartClientMediumRequest for the medium medium.�writingN��_medium�_state�r�mediums  rr�!SmartClientMediumRequest.__init__)s���� ��rc�r�URS:wa[R"U5eURU5 g)a@Accept bytes for inclusion in this request.

This method may not be called after finished_writing() has been
called.  It depends upon the Medium whether or not the bytes will be
immediately transmitted. Message based Mediums will tend to buffer the
bytes until finished_writing() is called.

:param bytes: A bytestring.
rN)rr�WritingCompleted�
_accept_bytesrCs  rr��%SmartClientMediumRequest.accept_bytes1s/���;�;�)�#��)�)�$�/�/����5�!rc�,�[UR5e)z�Helper for accept_bytes.

Accept_bytes checks the state of the request to determing if bytes
should be accepted. After that it hands off to _accept_bytes to do the
actual acceptance.
)rPrrCs  rr�&SmartClientMediumRequest._accept_bytes?s��"�$�"4�"4�5�5rc���URS:Xa[R"U5eURS:wa[R"U5eSUlUR	5 g)z�Inform the request that all desired data has been read.

This will remove the request from the pipeline for its medium (if the
medium supports pipelining) and any further calls to methods on the
request will raise ReadingCompleted.
r�reading�doneN)rr�WritingNotComplete�ReadingCompleted�_finished_readingr8s r�finished_reading�)SmartClientMediumRequest.finished_readingHsQ���;�;�)�#��+�+�D�1�1��;�;�)�#��)�)�$�/�/������� rc�,�[UR5e)z�Helper for finished_reading.

finished_reading checks the state of the request to determine if
finished_reading is allowed, and if it is hands off to _finished_reading
to perform the action.
)rPrr8s rr�*SmartClientMediumRequest._finished_readingV���"�$�"8�"8�9�9rc�~�URS:wa[R"U5eSUlUR5 g)z�Finish the writing phase of this request.

This will flush all pending data for this request along the medium.
After calling finished_writing, you may not call accept_bytes anymore.
rrN)rrr
�_finished_writingr8s r�finished_writing�)SmartClientMediumRequest.finished_writing_s4���;�;�)�#��)�)�$�/�/������� rc�,�[UR5e)z�Helper for finished_writing.

finished_writing checks the state of the request to determine if
finished_writing is allowed, and if it is hands off to _finished_writing
to perform the action.
)rPrr8s rr�*SmartClientMediumRequest._finished_writingjrrc��URS:Xa[R"U5eURS:wa[R"U5eUR	U5$)aRead bytes from this requests response.

This method will block and wait for count bytes to be read. It may not
be invoked until finished_writing() has been called - this is to ensure
a message-based approach to requests, for compatibility with message
based mediums like HTTP.
rr)rrrrrIrQs  rrL�#SmartClientMediumRequest.read_bytesssO���;�;�)�#��+�+�D�1�1��;�;�)�#��)�)�$�/�/�����&�&rc�8�URRU5$)a&Helper for SmartClientMediumRequest.read_bytes.

read_bytes checks the state of the request to determing if bytes
should be read. After that it hands off to _read_bytes to do the
actual read.

By default this forwards to self._medium.read_bytes because we are
operating on the medium's stream.
)rrLrQs  rrI�$SmartClientMediumRequest._read_bytes�s���|�|�&�&�u�-�-rc�~�UR5nURS5(d[R"S5eU$)Nr*zkUnexpected end of message. Please check connectivity and permissions, and report a bug if problems persist.)�
_read_line�endswithr�ConnectionReset)rr/s  r�	read_line�"SmartClientMediumRequest.read_line�s=����� ���}�}�U�#�#��(�(�I��
��rc�6�URR5$)z�Helper for SmartClientMediumRequest.read_line.

By default this forwards to self._medium._get_line because we are
operating on the medium's stream.
)rr1r8s rr(�#SmartClientMediumRequest._read_line�s���|�|�%�%�'�'rrN)rrrrr]rr�rrrrrrLrIr+r(rrrrrrs>���" �"�6�!�:�	!�:�'�
.��(rrc�$�\rSrSrSrSrSrSrg)�_VfsRefuseri�z(An object that refuses all VFS requests.c�n�[RRRSURS5 g)N�callzvfs refuser)�client�_SmartClient�hooks�install_named_hook�	check_vfsr8s rr�_VfsRefuser.__init__�s'�����!�!�4�4��D�N�N�M�	
rc��[RRUR5n[U[R5(a [URUR5eg![a gf=fr)
�request�request_handlers�getr�KeyError�
issubclass�vfs�
VfsRequestrr�)r�params�request_methods   rr7�_VfsRefuser.check_vfs�sb��	�$�5�5�9�9�&�-�-�H�N��n�c�n�n�5�5�*�6�=�=�&�+�+�F�F�6���	��	�s�)A+�+
A8�7A8rN)rrrrr]rr7rrrrr0r0�s��2�
�
Grr0c�6�\rSrSrSrSrSrSrSrSr	Sr
g	)
�
_DebugCounteri�z�An object that counts the HPSS calls made to each client medium.

When a medium is garbage-collected, or failing that when
breezy.global_state exits, the total number of calls made on that medium
are reported via trace.note.
c��[R5Ul[RR
R
SURS5 [R"5RRUR5 g)Nr2zhpss call counter)
�weakref�WeakKeyDictionary�countsr3r4r5r6�increment_call_count�breezy�get_global_state�
exit_stack�callback�	flush_allr8s rr�_DebugCounter.__init__�s]���/�/�1������!�!�4�4��D�-�-�/B�	
�	���!�,�,�5�5�d�n�n�Erc�~�[U5nSSUS.URU'[RXR5 g)z|Start tracking calls made to a medium.

This only keeps a weakref to the medium, so shouldn't affect the
medium's lifetime.
r)rR�	vfs_count�medium_reprN)�reprrIrG�refr)rr
rSs   r�track�_DebugCounter.track�s4���6�l��()��+�V����F��
	���F�I�I�&rc��URURnUS==S-
ss'[RR	UR
5n[U[R5(aUS==S-
ss'gg![a gf=f)NrRr)rR)
rIr
r:r;r<rr=r>r?r@)rrA�valuerBs    rrJ�"_DebugCounter.increment_call_count�s}�����F�M�M�*��
�g��!���	�$�5�5�9�9�&�-�-�H�N��n�c�n�n�5�5��+��!�#��6���	��	�s�)A?�?
B�Bc��URUnUSUSUSpTnSUS'SUS'US:wa/[R[S5R	X4U55 gg)NrRrRrSrzHPSS calls: {0} ({1} vfs) {2})rIrprq�gettextr>)rrUrYrRrRrSs      rr�_DebugCounter.done�st�����C� ���'�N��+���-� �&����g����k���A�:��J�J��7�8�?�?��k��
�rc�z�[URR55HnURU5 M gr)�listrI�keysr)rrUs  rrO�_DebugCounter.flush_all�s)������(�(�*�+�C��I�I�c�N�,r)rIN)rrrrr]rrVrJrrOrrrrrErE�s!���F�
'�
$��&rrEc�P^�\rSrSrSrU4SjrSrSrSrSr	Sr
S	rS
rU=r
$)�SmartClientMediumi�zBSmart client is a medium for sending smart protocol requests over.c�(>�[TU]5 XlSUlSUlSUlSUlS[R;a&[c
[5q	[RU5 S[R;a[c[5qggg)NFr��hpss_client_no_vfs)r�r�base�_protocol_version_error�_protocol_version�_done_hello�_remote_version_is_beforer�r��_debug_counterrErV�_vfs_refuserr0)rrfr�s  �rr�SmartClientMedium.__init__�s����
�����	�'+��$�!%��� ���
*.��&��U�&�&�&��%�!.���� � ��&��5�#4�#4�4��#�*�}��$�5rc�:�URcgXR:�$)a�Is it possible the remote side supports RPCs for a given version?

Typical use::

    needed_version = (1, 2)
    if medium._is_remote_before(needed_version):
        fallback_to_pre_1_2_rpc()
    else:
        try:
            do_1_2_rpc()
        except UnknownSmartMethod:
            medium._remember_remote_is_before(needed_version)
            fallback_to_pre_1_2_rpc()

:seealso: _remember_remote_is_before
F)rj�r�
version_tuples  r�_is_remote_before�#SmartClientMedium._is_remote_befores"��"�)�)�1��� >� >�>�>rc�$�URb}XR:�an[RSUUR5 S[R;a8[
RRSRXR55 gXlg)z_Tell this medium that the remote side is older the given version.

:seealso: _is_remote_before
Nz`_remember_remote_is_before(%r) called, but _remember_remote_is_before(%r) was called previously.r�zd_remember_remote_is_before({!r}) called, but _remember_remote_is_before({!r}) was called previously.)	rjrpr{r�r�rWrX�show_warningr>ros  r�_remember_remote_is_before�,SmartClientMedium._remember_remote_is_before's���
�*�*�6�� >� >�>�
�L�L�H���.�.�	
���*�*�*��
�
�*�*�N�NT�f�%�'E�'E�O��
�)6�&rc��URbUReUR(d>UR5n[R	U5nUR5 SUlgg![RanX0leSnAff=f)z(Find out if 'hello' smart request works.NT�2)rgri�get_requestr�SmartClientRequestProtocolOne�
query_versionr�SmartProtocolError)r�medium_request�client_protocolrws    r�protocol_version�"SmartClientMedium.protocol_versionDs����'�'�3��.�.�.����
�!%�!1�!1�!3��#+�"H�"H��"X���-�-�/�#'�� ����,�,�
�01�,���	
�s�<A*�*B
�>B�B
c��g)a:Should RemoteBzrDirFormat.probe_transport send a smart request on
this medium?

Some transports are unambiguously smart-only; there's no need to check
if the transport is able to carry smart requests, because that's all
it is for.  In those cases, this method should return False.

But some HTTP transports can sometimes fail to carry smart requests,
but still be usuable for accessing remote bzrdirs via plain file
accesses.  So for those transports, their media should return True here
so that RemoteBzrDirFormat can determine if it is appropriate for that
transport.
Frr8s r�should_probe�SmartClientMedium.should_probeWs��rc��g)zfIf this medium maintains a persistent connection, close it.

The default implementation does nothing.
Nrr8s r�
disconnect�SmartClientMedium.disconnectgr�rc��[RURS5n[RX!R5n[R	U5$)z�Convert transport into a path suitable for using in a request.

Note that the resulting remote path doesn't encode the host name or
anything but path, so it is only safe to use it in requests sent over
the medium from the matching transport.
r�)�urlutils�joinrf�relative_url�unquote)r�	transport�medium_base�rel_urls    r�remote_path_from_transport�,SmartClientMedium.remote_path_from_transportms=���m�m�D�I�I�s�3���'�'��^�^�D������(�(r)rirhrgrjrf)rrrrr]rrqrurr�r�r�rrrs@rrcrc�s.���L�-�,?�,7�:�&� �	)�	)rrcc�<�\rSrSrSrSrSrSrSrSr	Sr
S	rg
)�SmartClientStreamMediumiyaStream based medium common class.

SmartClientStreamMediums operate on a stream. All subclasses use a common
SmartClientStreamMediumRequest for their requests, and should implement
_accept_bytes and _read_bytes to allow the request objects to send and
receive bytes.
c�<�[RX5 SUlgr)rcr�_current_request�rrfs  rr� SmartClientStreamMedium.__init__�s���"�"�4�.� $��rc�&�URU5 gr)rrCs  rr��$SmartClientStreamMedium.accept_bytes�s�����5�!rc�$�UR5 g)zWThe SmartClientStreamMedium knows how to close the stream when it is
finished with it.
N)r�r8s r�__del__�SmartClientStreamMedium.__del__�s��	
���rc�,�[UR5e)z�Flush the output stream.

This method is used by the SmartClientStreamMediumRequest to ensure that
all data for a request is sent, to avoid long timeouts or deadlocks.
)rP�_flushr8s rr��SmartClientStreamMedium._flush�s��"�$�+�+�.�.rc��[U5$)zSee SmartClientMedium.get_request().

SmartClientStreamMedium always returns a SmartClientStreamMediumRequest
for get_request.
)�SmartClientStreamMediumRequestr8s rry�#SmartClientStreamMedium.get_request�s��.�d�3�3rc�2�UR5 SUlg)zoWe have been disconnected, reset current state.

This resets things like _current_request and connected state.
N)r�r�r8s r�reset�SmartClientStreamMedium.reset�s��
	
���� $��r)r�N)rrrrr]rr�r�r�ryr�rrrrr�r�ys%���%�"��/�4�%rr�c�0�\rSrSrSrSrSrSrSrSr	g)	�SmartSimplePipesClientMediumi�zqA client medium using simple pipes.

This client does not manage the pipes: it assumes they will always be open.
c�F�[RX5 XlX lgr)r�r�_readable_pipe�_writeable_pipe)r�
readable_pipe�writeable_piperfs    rr�%SmartSimplePipesClientMedium.__init__�s���(�(��4�+��-�rc�$�URRU5 UR[U5S5 g![aLnUR[R[R
4;a[R"SU5UeeSnAff=f)�)See SmartClientStreamMedium.accept_bytes.z#Error trying to write to subprocessNru)
r�rur�r��EINVAL�EPIPErr*r[r )rr?rws   rr�*SmartSimplePipesClientMedium._accept_bytes�s|��	�� � �&�&�t�,�	
���c�$�i��1��
�	��w�w�5�<�<����5�5��,�,�9�1����
��	�s�9�
B�AB
�
Bc�8�URR5 g�z%See SmartClientStreamMedium._flush().N)r�r�r8s rr��#SmartSimplePipesClientMedium._flush�s��
	
���"�"�$rc��[U[5nURRU5nUR	[U5S5 U$)z(See SmartClientStreamMedium._read_bytes.r�)rGrHr�r�r[r )rrRrKr?s    rrI�(SmartSimplePipesClientMedium._read_bytes�s=���E�>�2�
��"�"�'�'�
�6�����c�$�i��0��r)r�r�N)
rrrrr]rrr�rIrrrrr�r��s���
.�

2�%�rr�c�$�\rSrSrSrSSjrSrg)�	SSHParamsi�z6A set of parameters for starting a remote bzr via SSH.Nc�@�XlX lX0lX@lXPlgr)�host�port�username�password�bzr_remote_path)rr�r�r�r�r�s      rr�SSHParams.__init__�s���	��	� �
� �
�.�r)r�r�r�r�r�)NNN�bzr)rrrrr]rrrrrr�r��s��@�NS�/rr�c�F�\rSrSrSrSSjrSrSrSrSr	S	r
S
rSrg)
�SmartSSHClientMediumi�z�A client medium using SSH.

It delegates IO to a SmartSimplePipesClientMedium or
SmartClientAlreadyConnectedSocketMedium (depending on platform).
Nc�p�SUlX lSUl[R	X5 X0lSUlg)z�Creates a client that will connect on the first use.

:param ssh_params: A SSHParams instance.
:param vendor: An optional override for the ssh vendor to use. See
    breezy.transport.ssh for details on ssh vendors.
Nzbzr+ssh)�_real_medium�_ssh_params�_schemer�r�_vendor�_ssh_connection)rrf�
ssh_params�vendors    rr�SmartSSHClientMedium.__init__�s8��!���%��!���	 �(�(��4���#��rc��URRcSnO%SRURR5nURRcSnO%SRURR5nSRURR
URUURRU5$)N�z:{}z{}@z{}({}://{}{}{}/))r�r�r>r�r�rr�r�)r�
maybe_port�
maybe_users   rr��SmartSSHClientMedium.__repr__�s������ � �(��J����d�&6�&6�&;�&;�<�J����$�$�,��J����d�&6�&6�&?�&?�@�J�!�(�(��N�N�#�#��L�L�����!�!��
�	
rc�Z�UR5 URRU5 g)r�N)�_ensure_connectionr�r�rCs  rr�"SmartSSHClientMedium._accept_bytess"�����!����&�&�u�-rc��URb!URR5 SUlURb"URR5 SUlgg)�#See SmartClientMedium.disconnect().N)r�r�r�r�r8s rr��SmartSSHClientMedium.disconnectsS�����(����(�(�*� $�D�����+�� � �&�&�(�#'�D� �,rc���URbgURc[R5nOURnUR	UR
RUR
RUR
RUR
RUR
RSSSS/S9UlURR5up#US:Xa[URU5UlOJUS:Xa UupE[XEUR5UlO$[!S	R#X R55e[$R&R(S
HnU"U5 M
 g)�-Connect this medium if not already connected.Nrxz--inetz
--directory=/z--allow-writes)�commandr��pipesz!Unexpected io_kind {!r} from {!r}�post_connect)r�r��ssh�_get_ssh_vendor�connect_sshr�r�r�r�r�r�r��get_sock_or_pipes�'SmartClientAlreadyConnectedSocketMediumrfr�r=r>r��	Transportr5)rr��io_kind�	io_object�	read_from�write_to�hooks       rr��'SmartSSHClientMedium._ensure_connectionsO�����(���<�<���(�(�*�F��\�\�F�%�1�1����%�%����%�%����!�!����!�!�� � �0�0���� �� 2� 
���"�1�1�C�C�E����h�� G��	�	�9�!�D����
�"+��I� <��T�Y�Y�!�D��!�3�:�:��1�1���
�
�'�'�-�-�n�=�D���J�>rc�8�URR5 gr�)r�r�r8s rr��SmartSSHClientMedium._flush<s����� � �"rc�~�URc[R"U5eURRU5$)z'See SmartClientStreamMedium.read_bytes.)r�r�MediumNotConnectedrLrQs  rrI� SmartSSHClientMedium._read_bytes@s6�����$��+�+�D�1�1�� � �+�+�E�2�2r)r�r�r�r�r�r)
rrrrr]rr�rr�r�r�rIrrrrr�r��s+���$�&
�".�
(�&�P#�3rr�i;c�<�\rSrSrSrSrSrSrSrSr	Sr
S	rg
)�SmartClientSocketMediumiLzgA client medium using a socket.

This class isn't usable directly.  Use one of its subclasses instead.
c�J�[RX5 SUlSUlg)NF)r�r�_socket�
_connectedr�s  rr� SmartClientSocketMedium.__init__Rs���(�(��4������rc�z�UR5 [R"URXR5 g)z#See SmartClientMedium.accept_bytes.N)r�rr�r�r[rCs  rr�%SmartClientSocketMedium._accept_bytesWs(�����!�������u�.C�.C�Drc�,�[UR5e)r�)rPr�r8s rr��*SmartClientSocketMedium._ensure_connection\s��!�$�"9�"9�:�:rc��g)z�See SmartClientStreamMedium._flush().

For sockets we do no flushing. For TCP sockets we may want to turn off
TCP_NODELAY and add a means to do a flush, but that can be done in the
future.
Nrr8s rr��SmartClientSocketMedium._flush`r�rc��UR(d[R"U5e[R"UR
UR5$)z!See SmartClientMedium.read_bytes.)r�rr�rr�r�r[rQs  rrI�#SmartClientSocketMedium._read_byteshs7������+�+�D�1�1��-�-�d�l�l�D�<Q�<Q�R�Rrc�x�UR(dgURR5 SUlSUlg)r�NF)r�r�r�r8s rr��"SmartClientSocketMedium.disconnectns*�����������������r�r�r�N)rrrrr]rrr�r�rIr�rrrrr�r�Ls'���
 �
E�
;��S� rr�c�$�\rSrSrSrSrSrSrg)�SmartTCPClientMediumiwz.A client medium that creates a TCP connection.c�F�[RX5 XlX lg)z4Creates a client that will connect on the first use.N)r�r�_host�_port)rr�r�rfs    rr�SmartTCPClientMedium.__init__zs���(�(��4��
��
rc	���UR(agURc[nO[UR5n[RURU[R[RSS5n[RSRUR55nUHwupxp�n[R	XxU	5UlURR![R"[R$S5 URR'U5  O URcd[-UR[.5(a
URnOURSn[R"SURSUSU35eS	Ul[0R2R4S
Hn
U
"U5 M
 g![Ra=nURupE[R"SURSUSU35UeSnAff=f![(a<nURbURR+5 SUlUnSnAGM�SnAff=f)r�Nrzfailed to lookup �:z: zno address found for {}r)zfailed to connect to Tr�)r�r�BZR_DEFAULT_PORT�intr��getaddrinfor�	AF_UNSPEC�SOCK_STREAM�gaierrorr�r�ConnectionError�errorr>r��
setsockopt�IPPROTO_TCP�TCP_NODELAY�connectr�r�r;�strr�r�r5)rr��	sockaddrs�xxx_todo_changeme�err_num�err_msg�last_err�family�socktype�proto�
_canonname�sockaddrr�r�s              rr��'SmartTCPClientMedium._ensure_connection�s����?�?���:�:��#�D��t�z�z�?�D�	%��*�*��
�
�D�&�"2�"2�F�4F�4F��1��I��<�<� 9� @� @���� L�M��=F�9�F�e��	
�%�}�}�V�u�E������'�'��(:�(:�F�<N�<N�PQ�R����$�$�X�.�
�>G��<�<���(�-�-��-�-�"�-�-��"�-�-��*���(�(�'��
�
�|�1�T�F�"�W�I�F��
�����'�'�-�-�n�=�D���J�>��=���	%�!2�!7�!7��W��(�(�#�D�J�J�<�q���b��	�B��$�
%��	%���
��<�<�+��L�L�&�&�(�#�������
�s1�AG
�5A/H!�
H�!8H�H�!
I'�+0I"�"I')r�rrr�N�rrrrr]rr�rrrrr�r�ws��8��+rr�c�$�\rSrSrSrSrSrSrg)r�i�z�A client medium for an already connected socket.

Note that this class will assume it "owns" the socket, so it will close it
when its disconnect method is called.
c�H�[RX5 X lSUlgr�)r�rr�r�)rrfr�s   rr�0SmartClientAlreadyConnectedSocketMedium.__init__�s���(�(��4�����rc��grrr8s rr��:SmartClientAlreadyConnectedSocketMedium._ensure_connection�s��rr�Nrrrrr�r��s����

rr�c��\rSrSrSrSrSrg)�TooManyConcurrentRequestsi�z�The medium '%(medium)s' has reached its concurrent request limit. Be sure to finish_writing and finish_reading on the currently open request.c��Xlgr�r
r	s  rr�"TooManyConcurrentRequests.__init__�s���rr'Nrrrrr%r%�s��	#�	�rr%c�0�\rSrSrSrSrSrSrSrSr	g)	r�i�zFA SmartClientMediumRequest that works with an SmartClientStreamMedium.c��[RX5 URRb[	UR5eXRlgr)rrrr�r%r	s  rr�'SmartClientStreamMediumRequest.__init__�s;�� �)�)�$�7��<�<�(�(�4�+�D�L�L�9�9�(,���%rc�:�URRU5 g)z�See SmartClientMediumRequest._accept_bytes.

This forwards to self._medium._accept_bytes because we are operating
on the mediums stream.
N)rrrCs  rr�,SmartClientStreamMediumRequest._accept_bytes�s��	
���"�"�5�)rc�l�URRULa
[5eSURlg)z�See SmartClientMediumRequest._finished_reading.

This clears the _current_request on self._medium to allow a new
request to be created.
N)rr�r=r8s rr�0SmartClientStreamMediumRequest._finished_reading�s+���<�<�(�(��4� �"�"�(,����%rc�8�URR5 g)zwSee SmartClientMediumRequest._finished_writing.

This invokes self._medium._flush to ensure all bytes are transmitted.
N)rr�r8s rr�0SmartClientStreamMediumRequest._finished_writing�s��
	
�����rrN)
rrrrr]rrrrrrrrr�r��s��P�	-�*�-�rr�)-r]r�r�r�r�rlr�rKr�globalsr�rrr�rH�BzrErrorrr&r1r3�EBADFr�r��WSAENOTSOCKr`r�r�rr0rErkrlrcr�r�r�r��BZR_DEFAULT_INTERFACErr�r�r��InternalBzrErrorr%r�rrr�<module>r8s���"���	�	�
��
�&���I���& ��)�)��#�v���#�#�@�,FH�FH�R���~���<�<�7���K��[�N�*��]4�k�]4�@K�$;�K�\R�"9�R�jF(�F(�RG�G�$?�?�D����~)��~)�B,%�/�,%�^#�#:�#�L
/�
/�i3�2�i3�Z����( �5�( �V4�2�4�n
�.E�
�"�� 7� 7��%�%=�%r

Youez - 2016 - github.com/yon3zu
LinuXploit