Sindbad~EG File Manager
�
�X�f�k��l�dZddlZddlZddlZddlZddlZeed�redz
ZddlmZddlm Z ddlm
Z
dd lmZdd
lmZddl
mZddlmZd
Zded�d�Zded�d�Zeed�rded�d�Zded�d�ZGd�dej,�ZGd�deej,�ZGd�d�ZGd�d�Zy))�StreamReader�StreamWriter�StreamReaderProtocol�open_connection�start_server�N�AF_UNIX)�open_unix_connection�start_unix_server�)�
coroutines)�events)�
exceptions)�format_helpers)� protocols)�logger)�sleepi)�limitc���� K�tj�}t||��}t||��� |j� fd�||fi|���d{���\}}t|� ||�}||fS7��w)a�A wrapper for create_connection() returning a (reader, writer) pair.
The reader returned is a StreamReader instance; the writer is a
StreamWriter instance.
The arguments are all the usual arguments to create_connection()
except protocol_factory; most common are positional host and port,
with various optional keyword arguments following.
Additional optional keyword arguments are loop (to set the event loop
instance to use) and limit (to set the buffer limit passed to the
StreamReader).
(If you want to customize the StreamReader and/or
StreamReaderProtocol classes, just copy the code -- there's
really nothing special here except some convenience.)
�r�loop�rc����S�N���protocols��-/usr/src/Python-3.12.7/Lib/asyncio/streams.py�<lambda>z!open_connection.<locals>.<lambda>1s����N)r
�get_running_looprr�create_connectionr)
�host�portr�kwdsr�reader� transport�_�writerrs
@rrrsx�����&�"�"�$�D�
��D�
1�F�#�F��6�H�/��/�/��$��.�(,�.�.�L�I�q�
�)�X�v�t�
<�F��6�>��.�s�A
A)�
A'�A)c�����K�tj�����fd�}�j|||fi|���d{���S7��w)a�Start a socket server, call back for each client connected.
The first parameter, `client_connected_cb`, takes two parameters:
client_reader, client_writer. client_reader is a StreamReader
object, while client_writer is a StreamWriter object. This
parameter can either be a plain callback function or a coroutine;
if it is a coroutine, it will be automatically converted into a
Task.
The rest of the arguments are all the usual arguments to
loop.create_server() except protocol_factory; most common are
positional host and port, with various optional keyword arguments
following. The return value is the same as loop.create_server().
Additional optional keyword argument is limit (to set the buffer
limit passed to the StreamReader).
The return value is the same as loop.create_server(), i.e. a
Server object which can be used to stop the service.
c�>��t����}t|����}|S�Nrr�rr�r%r�client_connected_cbrrs ���r�factoryzstart_server.<locals>.factoryNs&����E��5��'��0C�-1�3���rN)r
r �
create_server)r.r"r#rr$r/rs` ` @rrr6s@�����,�"�"�$�D��$��#�#�G�T�4�@�4�@�@�@�@�s�4A�>�Ac����K�tj�}t||��}t||���|j�fd�|fi|���d{���\}}t|�||�}||fS7��w)z@Similar to `open_connection` but works with UNIX Domain Sockets.rrc����Srrrs�rrz&open_unix_connection.<locals>.<lambda>bs���HrN)r
r rr�create_unix_connectionr) �pathrr$rr%r&r'r(rs @rr r Zsv������&�&�(���E��5��'��T�:��8�T�8�8��d�,�&*�,�,�� �1��i��6�4�@���v�~��,�s�A A(�A&�
A(c�����K�tj�����fd�}�j||fi|���d{���S7��w)z=Similar to `start_server` but works with UNIX Domain Sockets.c�>��t����}t|����}|Sr+r,r-s ���rr/z"start_unix_server.<locals>.factoryks&���!��D�9�F�+�F�4G�15�7�H��OrN)r
r �create_unix_server)r.r4rr$r/rs` ` @rr
r
fs>������&�&�(�� �-�T�,�,�W�d�C�d�C�C�C�C�s�3?�=�?c�6�eZdZdZd d�Zd�Zd�Zd�Zd�Zd�Z y)
�FlowControlMixina)Reusable flow control logic for StreamWriter.drain().
This implements the protocol methods pause_writing(),
resume_writing() and connection_lost(). If the subclass overrides
these it must call the super methods.
StreamWriter.drain() must wait for _drain_helper() coroutine.
Nc��|�tj�|_n||_d|_t j
�|_d|_y�NF)r
�get_event_loop�_loop�_paused�collections�deque�_drain_waiters�_connection_lost)�selfrs r�__init__zFlowControlMixin.__init__~s>���<��.�.�0�D�J��D�J����)�/�/�1��� %��rc��|jrJ�d|_|jj�rtjd|�yy)NTz%r pauses writing)r>r=� get_debugr�debug�rCs r�
pause_writingzFlowControlMixin.pause_writing�s:���<�<�������:�:���!��L�L�,�d�3�"rc���|jsJ�d|_|jj�rtjd|�|j
D]$}|j
�r�|jd��&y)NFz%r resumes writing)r>r=rFrrGrA�done�
set_result�rC�waiters r�resume_writingzFlowControlMixin.resume_writing�s[���|�|��|�����:�:���!��L�L�-�t�4��)�)�F��;�;�=��!�!�$�'�*rc��d|_|jsy|jD]8}|j�r�|�|j d��(|j|��:y�NT)rBr>rArKrL�
set_exception�rC�excrNs r�connection_lostz FlowControlMixin.connection_lost�sN�� $����|�|���)�)�F��;�;�=��;��%�%�d�+��(�(��-�*rc��NK�|jrtd��|jsy|jj �}|j
j
|� |�d{���|j
j|�y7� #|j
j|�wxYw�w)NzConnection lost)rB�ConnectionResetErrorr>r=�
create_futurerA�append�removerMs r�
_drain_helperzFlowControlMixin._drain_helper�s������ � �&�'8�9�9��|�|�����)�)�+�����"�"�6�*� /��L�L����&�&�v�.�
�����&�&�v�.�s0�AB%�B�"B�#B�'B%�B�B"�"B%c��t�r)�NotImplementedError�rC�streams r�_get_close_waiterz"FlowControlMixin._get_close_waiter�s��!�!rr)
�__name__�
__module__�__qualname__�__doc__rDrIrOrUr[r`rrrr9r9ts%���&�4�(�.�
/�"rr9c�f��eZdZdZdZd�fd� Zed��Zd�Zd�Z �fd�Z
d�Zd �Zd
�Z
d�Z�xZS)
ra=Helper class to adapt between Protocol and StreamReader.
(This is a helper class instead of making StreamReader itself a
Protocol subclass, because the StreamReader has other potential
uses, and to prevent the user of the StreamReader to accidentally
call inappropriate methods of the protocol.)
Nc�4��t�|�|��|�,tj|�|_|j
|_nd|_|�||_d|_d|_d|_ d|_
||_d|_|jj�|_y)NrF)�superrD�weakref�ref�_stream_reader_wr�_source_traceback�_strong_reader�_reject_connection�_stream_writer�_task�
_transport�_client_connected_cb� _over_sslr=rX�_closed)rC�
stream_readerr.r� __class__s �rrDzStreamReaderProtocol.__init__�s����
���d��#��$�%,�[�[��%?�D�"�%2�%D�%D�D�"�%)�D�"��*�#0�D��"'���"�����
����$7��!�����z�z�/�/�1��rc�<�|j�y|j�Sr)rjrHs r�_stream_readerz#StreamReaderProtocol._stream_reader�s ���!�!�)���%�%�'�'rc��|j}|j}||_||_|j d�du|_y)N�
sslcontext)r=r&rnrp�get_extra_inforr)rCr(rr&s r�_replace_writerz$StreamReaderProtocol._replace_writer�s<���z�z���$�$� �$���#���"�1�1�,�?�t�K��rc�x����jrKddi}�jr�j|d<�jj|��j �y��_�j}|�|j���jd�du�_ �j��t��|�j��_�j|�j�}tj|�rA��fd�}�jj|��_�j j#|�d�_yy)N�messagezpAn open stream was garbage collected prior to establishing network connection; call "stream.close()" explicitly.�source_tracebackryc����|j�r�j�y|j�}|�0�jj d|�d���j�yy)Nz*Unhandled exception in client_connected_cb)r}� exceptionr&)� cancelled�closer�r=�call_exception_handler)�taskrTrCr&s ��r�callbackz6StreamReaderProtocol.connection_made.<locals>.callback�s\����~�~�'�!���)���.�.�*�C����
�
�9�9�'S�),�)2�;��
"���)�
'r)rmrkr=r��abortrprw�
set_transportrzrrrqrrnr�iscoroutine�create_taskro�add_done_callbackrl)rCr&�contextr%�resr�s`` r�connection_madez$StreamReaderProtocol.connection_made�s#����"�"��@��G�
�%�%�.2�.D�.D��*�+��J�J�-�-�g�6��O�O���#����$�$����� � ��+�"�1�1�,�?�t�K����$�$�0�".�y�$�/5�/3�z�z�#;�D���+�+�F�,0�,?�,?�A�C��%�%�c�*�*�"�Z�Z�3�3�C�8��
��
�
�,�,�X�6�"&�D��/1rc�f��|j}|�$|�|j�n|j|�|jj �s9|�|jjd�n|jj|�t�|�|�d|_d|_ d|_
d|_yr)rw�feed_eofrRrsrKrLrgrUrjrnrorp)rCrTr%rus �rrUz$StreamReaderProtocol.connection_lost
s�����$�$�����{����!��$�$�S�)��|�|� � �"��{����'�'��-����*�*�3�/�
����$�!%���"�����
���rc�D�|j}|�|j|�yyr)rw� feed_data)rC�datar%s r�
data_receivedz"StreamReaderProtocol.data_receiveds&���$�$�������T�"�rc�Z�|j}|�|j�|jryy)NFT)rwr�rr)rCr%s r�eof_receivedz!StreamReaderProtocol.eof_received!s,���$�$�����O�O���>�>��rc��|jSr)rsr^s rr`z&StreamReaderProtocol._get_close_waiter,s���|�|�rc�� |j}|j�r"|j�s|j�yyy#t$rYywxYwr)rsrKr�r��AttributeError)rC�closeds r�__del__zStreamReaderProtocol.__del__/sM�� #��\�\�F��{�{�}�V�%5�%5�%7�� � �"�&8�}��� �� �s�A� A
�A
�NN)rarbrcrdrkrD�propertyrwr{r�rUr�r�r`r��
__classcell__)rus@rrr�sN������2�(�(��(�
L�('�T�$#�
�� #rrc�z�eZdZdZd�Zd�Zed��Zd�Zd�Z d�Z
d�Zd �Zd
�Z
d�Zdd
�Zd�Zdddd�d�Zd�Zy)ra'Wraps a Transport.
This exposes write(), writelines(), [can_]write_eof(),
get_extra_info() and close(). It adds drain() which returns an
optional Future on which you can wait for flow control. It also
adds a transport property which references the Transport
directly.
c���||_||_|�t|t�sJ�||_||_|j
j
�|_|jjd�yr) rp� _protocol�
isinstancer�_readerr=rX�
_complete_futrL)rCr&rr%rs rrDzStreamWriter.__init__Es[��#���!����~��F�L�!A�A�A������
�!�Z�Z�5�5�7������%�%�d�+rc���|jjd|j��g}|j�|j d|j���djdj
|��S)N�
transport=zreader=�<{}>� )rurarpr�rY�format�join�rC�infos r�__repr__zStreamWriter.__repr__Os[�����'�'�:�d�o�o�5H�)I�J���<�<�#��K�K�'�$�,�,�!1�2�3��}�}�S�X�X�d�^�,�,rc��|jSr�rprHs rr&zStreamWriter.transportUs�����rc�:�|jj|�yr)rp�write�rCr�s rr�zStreamWriter.writeYs�������d�#rc�:�|jj|�yr)rp�
writelinesr�s rr�zStreamWriter.writelines\s�����"�"�4�(rc�6�|jj�Sr)rp� write_eofrHs rr�zStreamWriter.write_eof_s�����(�(�*�*rc�6�|jj�Sr)rp�
can_write_eofrHs rr�zStreamWriter.can_write_eofbs�����,�,�.�.rc�6�|jj�Sr)rpr�rHs rr�zStreamWriter.closees�����$�$�&�&rc�6�|jj�Sr)rp�
is_closingrHs rr�zStreamWriter.is_closinghs�����)�)�+�+rc��VK�|jj|��d{���y7��wr)r�r`rHs r�wait_closedzStreamWriter.wait_closedks�����n�n�.�.�t�4�4�4�s�)�'�)Nc�:�|jj||�Sr)rprz)rC�name�defaults rrzzStreamWriter.get_extra_infons�����-�-�d�G�<�<rc��K�|j�|jj�}|�|�|jj�rt d��d{���|j
j
��d{���y7�'7��w)zyFlush the write buffer.
The intended use is to write
w.write(data)
await w.drain()
Nr)r�r�rpr�rr�r[)rCrTs r�drainzStreamWriter.drainqsj�����<�<�#��,�,�(�(�*�C���� ��?�?�%�%�'���(�N�N��n�n�*�*�,�,�,�
��,�s$�AB�A=�!B�7A?�8B�?B)�server_hostname�ssl_handshake_timeout�ssl_shutdown_timeoutc ��$K�|jjdu}|j}|j��d{���|jj |j
||||||���d{���}||_|j
|�y7�Q7��w)z3Upgrade an existing stream-based connection to TLS.N)�server_sider�r�r�)r�rqr�r=� start_tlsrpr{)rCryr�r�r�r�r�
new_transports rr�zStreamWriter.start_tls�s�����
�n�n�9�9��E���>�>���j�j�l���"�j�j�2�2��O�O�X�z�#�_�"7�!5� 3�7�7�
�
(���� � ��&� ��7�s!�8B�B�3B�.B�/B�Bc��|jj�sc|jj�rt j
dt�y|j�t j
d|��t�yy)Nzloop is closedz unclosed )rpr�r=� is_closed�warnings�warn�ResourceWarningr�rHs rr�zStreamWriter.__del__�sT�����)�)�+��z�z�#�#�%��
�
�.��@��
�
���
�
� �$��2�O�D�,rr)rarbrcrdrDr�r�r&r�r�r�r�r�r�r�rzr�r�r�rrrrr;sh���,�-�����$�)�+�/�'�,�5�=�-�4)-�.2�-1�'� Errc��eZdZdZedfd�Zd�Zd�Zd�Zd�Z d�Z
d�Zd �Zd
�Z
d�Zd�Zd
�Zdd�Zdd�Zd�Zd�Zd�Zy)rNc�l�|dkrtd��||_|�tj�|_n||_t�|_d|_d|_d|_ d|_
d|_|jj�r.tjtj d��|_yy)NrzLimit cannot be <= 0Fr)�
ValueError�_limitr
r<r=� bytearray�_buffer�_eof�_waiter�
_exceptionrpr>rFr�
extract_stack�sys� _getframerk)rCrrs rrDzStreamReader.__init__�s����A�:��3�4�4�����<��.�.�0�D�J��D�J� �{����� ��������������:�:���!�%3�%A�%A��
�
�a� �&"�D�"�"rc��dg}|jr'|jt|j��d��|jr|jd�|jt
k7r|jd|j���|jr|jd|j���|jr|jd|j���|jr|jd|j���|jr|jd�d jd
j|��S)Nrz bytes�eofzlimit=zwaiter=z
exception=r��pausedr�r�)r�rY�lenr�r��_DEFAULT_LIMITr�r�rpr>r�r�r�s rr�zStreamReader.__repr__�s�������<�<��K�K�3�t�|�|�,�-�V�4�5��9�9��K�K����;�;�.�(��K�K�&����
�.�/��<�<��K�K�'�$�,�,�!1�2�3��?�?��K�K�*�T�_�_�$7�8�9��?�?��K�K�*�T�_�_�$7�8�9��<�<��K�K��!��}�}�S�X�X�d�^�,�,rc��|jSr)r�rHs rr�zStreamReader.exception�s�����rc��||_|j}|�*d|_|j�s|j|�yyyr)r�r�r�rRrSs rrRzStreamReader.set_exception�sC������������D�L��#�#�%��$�$�S�)�&�rc�t�|j}|�*d|_|j�s|jd�yyy)z1Wakeup read*() functions waiting for data or EOF.N)r�r�rLrMs r�_wakeup_waiterzStreamReader._wakeup_waiter�s<���������D�L��#�#�%��!�!�$�'�&�rc�8�|j�Jd��||_y)NzTransport already setr�)rCr&s rr�zStreamReader.set_transport�s�����&�?�(?�?�&�#��rc��|jrEt|j�|jkr"d|_|jj�yyyr;)r>r�r�r�rp�resume_readingrHs r�_maybe_resume_transportz$StreamReader._maybe_resume_transport�s;���<�<�C����-����<� �D�L��O�O�*�*�,�=�<rc�2�d|_|j�yrQ)r�r�rHs rr�zStreamReader.feed_eof�s���� ����rc�8�|jxr
|jS)z=Return True if the buffer is empty and 'feed_eof' was called.)r�r�rHs r�at_eofzStreamReader.at_eof�s���y�y�-����-�-rc�v�|jrJd��|sy|jj|�|j�|j�V|j
sIt
|j�d|jzkDr# |jj�d|_yyyy#t$r
d|_YywxYw)Nzfeed_data after feed_eof�T)
r�r��extendr�rpr>r�r��
pause_readingr]r�s rr�zStreamReader.feed_data�s����9�9�8�8�8�}��������D�!������O�O�'��L�L��D�L�L�!�A����O�3�
$����-�-�/� $���4�!�
(��
'�
'�#'���
'�s�B%�%B8�7B8c��RK�|j�t|�d���|jrJd��|jr!d|_|jj�|jj�|_ |j�d{���d|_y7�#d|_wxYw�w)zpWait until feed_data() or feed_eof() is called.
If stream was paused, automatically resume it.
NzF() called while another coroutine is already waiting for incoming dataz_wait_for_data after EOFF)r��RuntimeErrorr�r>rpr�r=rX)rC� func_names r�_wait_for_datazStreamReader._wait_for_data s������<�<�#���+�4�5�6�
6��9�9�8�8�8�}��<�<� �D�L��O�O�*�*�,��z�z�/�/�1��� ��,�,����D�L�
���D�L�s0�A:B'�=B�B�
B�B'�B� B$�$B'c���K�d}t|�} |j|��d{���}|S7�#tj$r}|jcYd}~Sd}~wtj
$r�}|jj||j�r|jd|j|z�=n|jj�|j�t|jd��d}~wwxYw�w)a�Read chunk of data from the stream until newline (b'
') is found.
On success, return chunk that ends with newline. If only partial
line can be read due to EOF, return incomplete line without
terminating newline. When EOF was reached while no bytes read, empty
bytes object is returned.
If limit is reached, ValueError will be raised. In that case, if
newline was found, complete line including newline will be removed
from internal buffer. Else, internal buffer will be cleared. Limit is
compared against part of the line without newline.
If stream was paused, this function will automatically resume it if
needed.
�
Nr)
r�� readuntilr�IncompleteReadError�partial�LimitOverrunErrorr��
startswith�consumed�clearr�r��args)rC�sep�seplen�line�es r�readlinezStreamReader.readline%s����� ���S���
(�����,�,�D���-���-�-� ��9�9����+�+� (��|�|�&�&�s�A�J�J�7��L�L�!5�!�*�*�v�"5�!5�6����"�"�$��(�(�*��Q�V�V�A�Y�'�'��
(�sJ�C5�.�,�.�C5�.�C2�A�C2�
C5�C2�(BC-�-C2�2C5c���K�t|�}|dk(rtd��|j�|j�d} t|j�}||z
|k\rO|jj ||�}|dk7rn�|dz|z
}||j
kDrt
jd|��|jrEt|j�}|jj�t
j|d��|jd��d{�����||j
kDrt
jd|��|jd||z}|jd||z�=|j�t|�S7�i�w) aVRead data from the stream until ``separator`` is found.
On success, the data and separator will be removed from the
internal buffer (consumed). Returned data will include the
separator at the end.
Configured stream limit is used to check result. Limit sets the
maximal length of data that can be returned, not counting the
separator.
If an EOF occurs and the complete separator is still not found,
an IncompleteReadError exception will be raised, and the internal
buffer will be reset. The IncompleteReadError.partial attribute
may contain the separator partially.
If the data cannot be read because of over limit, a
LimitOverrunError exception will be raised, and the data
will be left in the internal buffer, so it can be read again.
rz,Separator should be at least one-byte stringN���rz2Separator is not found, and chunk exceed the limitr�z2Separator is found, but chunk is longer than limit)r�r�r�r��findr�rr�r��bytesr�r�r�r�)rC� separatorr��offset�buflen�isep�chunks rr�zStreamReader.readuntilDsz����(�Y����Q�;��K�L�L��?�?�&��/�/�!�*�������&�F����&�(��|�|�(�(��F�;���2�:�� �!��f�,���D�K�K�'�$�6�6�L�� � ��y�y��d�l�l�+�����"�"�$� �4�4�U�D�A�A��%�%�k�2�2�2�=�@�$�+�+���.�.�D�d�L�
L����^�d�V�m�,���L�L��$��-��(��$�$�&��U�|��
3�s�DE6�
E4�A*E6c���K�|j�|j�|dk(ry|dkrLg} |j|j��d{���}|sn|j|��8dj |�S|j
s%|js|jd��d{���tt|j
�d|�}|j
d|�=|j�|S7��7�H�w)a�Read up to `n` bytes from the stream.
If `n` is not provided or set to -1,
read until EOF, then return all read bytes.
If EOF was received and the internal buffer is empty,
return an empty bytes object.
If `n` is 0, return an empty bytes object immediately.
If `n` is positive, return at most `n` available bytes
as soon as at least 1 byte is available in the internal buffer.
If EOF is received before any byte is read, return an empty
bytes object.
Returned value is not limited with limit, configured at stream
creation.
If stream was paused, this function will automatically resume it if
needed.
Nrr�read)r�rr�rYr�r�r�r�r�
memoryviewr�)rC�n�blocks�blockr�s rrzStreamReader.read�s�����,�?�?�&��/�/�!���6���q�5�
�F��"�i�i����4�4�����
�
�e�$� �
�8�8�F�#�#��|�|�D�I�I��%�%�f�-�-�-��Z����-�b�q�1�2���L�L��!����$�$�&���5��
.�s&�AC)�C%�AC)�C'�AC)�'C)c��K�|dkrtd��|j�|j�|dk(ryt|j�|kr�|jrEt|j�}|jj
�tj||��|jd��d{���t|j�|kr��t|j�|k(r0t|j�}|jj
�n0tt|j�d|�}|jd|�=|j�|S7���w)a�Read exactly `n` bytes.
Raise an IncompleteReadError if EOF is reached before `n` bytes can be
read. The IncompleteReadError.partial attribute of the exception will
contain the partial read bytes.
if n is zero, return empty bytes object.
Returned value is not limited with limit, configured at stream
creation.
If stream was paused, this function will automatically resume it if
needed.
rz*readexactly size can not be less than zeroNr�readexactly)r�r�r�r�r�rr�rr�r�rr�)rCr
�
incompleter�s rrzStreamReader.readexactly�s����
�q�5��I�J�J��?�?�&��/�/�!���6���$�,�,��!�#��y�y�"�4�<�<�0�
����"�"�$� �4�4�Z��C�C��%�%�m�4�4�4�
�$�,�,��!�#��t�|�|���!�����&�D��L�L��� ���D�L�L�1�"�1�5�6�D����R�a�R� ��$�$�&���
5�s�B,E�.E�/E�BEc��|SrrrHs r� __aiter__zStreamReader.__aiter__�s���rc��XK�|j��d{���}|dk(rt�|S7��w)Nr)r�StopAsyncIteration)rC�vals r� __anext__zStreamReader.__anext__�s+�����M�M�O�#���#�:�$�$��
�$�s�*�(�*)r�)r)rarbrcrkr�rDr�r�rRr�r�r�r�r�r�r�rr�rrrrrrrrr�sf����+�$�"�,-�$�*�(�$�-�
�.�$�, �8�>Y�v1�f'�R�rrr�r)�__all__r?�socketr�r�rh�hasattr�rr
rrr�logr�tasksrr�rrr r
�Protocolr9rrrrrr�<module>r s���'���
�
���
�6�9���<�<�G����������� .��8A�+�A�B�6�9��
�)7�
�D�&4�D�="�y�)�)�="�@D#�+�Y�-?�-?�D#�NeE�eE�N`�`r
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists