Server IP : 15.235.198.142 / Your IP : 216.73.216.190 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ballsack 6.8.0-45-generic #45-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 30 12:02:04 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /lib/python3/dist-packages/landscape/lib/__pycache__/ |
Upload File : |
� �~�e{W � � � d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z ddl mZ dd l mZ dd l m Z ddl mZ ddl mZ dd l mZ ddl mZ ddlmZ ddlmZ ddlmZ G d� de� Z G d� de� Z G d� de � Z G d� de � Z G d� de� Z G d� d� Z G d� de� Z G d � d!e� Z G d"� d#� Z! G d$� d%e � Z" G d&� d'e� Z#y())a< Expose the methods of a remote object over AMP. This module implements an AMP-based protocol for performing remote procedure calls in a convenient and easy way. It's conceptually similar to DBus in that it supports exposing a Python object to a remote process, with communication happening over any Twisted-supported transport, e.g. Unix domain sockets. For example let's say we have a Python process "A" that creates an instance of this class:: class Greeter(object): def hello(self, name): return f"hi {name}!" greeter = Greeter() Process A can "publish" the greeter object by defining which methods are exposed remotely and opening a Unix socket for incoming connections:: factory = MethodCallServerFactory(greeter, ["hello"]) reactor.listenUNIX("/some/socket/path", factory) Then a second Python process "B" can connect to that socket and build a "remote" greeter object, i.e. a proxy that forwards method calls to the real greeter object living in process A:: factory = MethodCallClientFactory() reactor.connectUNIX("/some/socket/path", factory) def got_remote(remote_greeter): deferred = remote_greeter.hello("Ted") deferred.addCallback(lambda result: ... # result == "hi Ted!") factory.getRemoteObject().addCallback(got_remote) Note that when invoking a method via the remote proxy, the parameters are required to be serializable with bpickle, so they can be sent over the wire. See also:: http://twistedmatrix.com/documents/current/core/howto/amp.html for more details about the Twisted AMP protocol. � )�uuid4)�Deferred)� maybeDeferred)�succeed)�ReconnectingClientFactory)� ServerFactory)�AMP)�Argument)�Command)�CommandLocator)�Integer)�MAX_VALUE_LENGTH)�String)�xrange)�Failure)�bpicklec �, � e Zd ZdZd� Zd� Zed� � Zy)�MethodCallArgumentzA bpickle-compatible argument.c �, � t j |� S )zSerialize an argument.)r �dumps)�self�inobjects �3/usr/lib/python3/dist-packages/landscape/lib/amp.py�toStringzMethodCallArgument.toStringF � � ��}�}�X�&�&� c �, � t j |� S )zUnserialize an argument.)r �loads)r �instrings r � fromStringzMethodCallArgument.fromStringJ r r c �8 � t |� t j v S )z%Check if an argument is serializable.)�typer �dumps_table)�clsr s r �checkzMethodCallArgument.checkN s � � �H�~��!4�!4�4�4r N)�__name__� __module__�__qualname__�__doc__r r �classmethodr% � r r r r C s# � �(�'�'� �5� �5r r c � � e Zd ZdZy)�MethodCallErrorz*Raised when a L{MethodCall} command fails.N)r&