Spade

Mini Shell

Directory:~$ /proc/self/root/opt/alt/python37/lib/python3.7/site-packages/ssa/__pycache__/
Upload File

[Home] [System Details] [Kill Me]
Current File:~$ //proc/self/root/opt/alt/python37/lib/python3.7/site-packages/ssa/__pycache__/agent.cpython-37.pyc

B

��df�@sfdZddlZddlZddlmZmZddlmZddlm	Z	ddl
mZddlm
Z
Gd	d
�d
�ZdS)zH
This module contains contains classes implementing SSA Agent behaviour
�N)�Thread�current_thread�)�
agent_sock)�SSAError)�
create_socket)�RequestProcessorc@sFeZdZdZdd�Zdd�dd�Zddd	�d
d�Zded
�dd�ZdS)�SimpleAgentz 
    SSA Simple Agent class
    cCs
t�d�|_t�|_|��dS)N�agent)�loggingZ	getLogger�loggerr�request_processor�listen)�self�r�:/opt/alt/python37/lib/python3.7/site-packages/ssa/agent.py�__init__szSimpleAgent.__init__N)�returncCsFtt�}x8|��\}}t|j|fd�}|��|j�d|j�q
WdS)z(
        Start listening socket
        )�target�argsz[%s]
StartedN)	rrZacceptr�handle�startr�debug�name)rZ_socket�
connectionZaddress�trrrrszSimpleAgent.listenz
socket
object)rrc
Csn|jdd�}y|�|�}|j�|�Wn:tk
r`}z|j�dt�jt	|��Wdd}~XYnX|�
�dS)z�
        Handle incoming connection
        :param connection: socket object usable to
        send and receive data on the connection
        �ignore)�errorszHandled exception in [%s]:
%sN)Zmakefile�
read_inputr
rrr�errorrr�str�close)rrZfileobjZ
input_data�errrr*s
zSimpleAgent.handlezfile
object)�fileiorcCs8|��}|j�dt�jt|���|�tj|�	�dd�S)zy
        Read input data and return decoded json
        :param fileio: a file-like object providing read method
        z[%s] I received %i bytes: %sF)�strict)
�readr�inforr�len�encode�json�loads�strip)rr#�datarrrr:s
zSimpleAgent.read_input)	�__name__�
__module__�__qualname__�__doc__rrr�dictrrrrrr	s
r	)r0r)rZ	threadingrrZinternal.constantsrZinternal.exceptionsrZinternal.utilsrZmodules.processorrr	rrrr�<module>
s