%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/application/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/application/__pycache__/service.cpython-312.pyc

�

Ϫ�f�-��t�dZddlmZmZmZddlmZddlmZddl	m
Z
ddlmZddl
mZGd�d	e�Zee
e�Gd
�d��ZGd�d
e�Zee�Gd�d��ZGd�de�Zee�Gd�de��ZGd�de�Zee�Gd�d��Zdd�Zdd�Zgd�Zy)aa
Service architecture for Twisted.

Services are arranged in a hierarchy. At the leafs of the hierarchy,
the services which actually interact with the outside world are started.
Services can be named or anonymous -- usually, they will be named if
there is need to access them through the hierarchy (from a parent or
a sibling).

Maintainer: Moshe Zadka
�)�	Attribute�	Interface�implementer)�defer)�sob)�IPlugin)�
components)�namedAnyc�F�eZdZdZed�Zed�Zed�Zd�Zy)�
IServiceMakerz�
    An object which can be used to construct services in a flexible
    way.

    This interface should most often be implemented along with
    L{twisted.plugin.IPlugin}, and will most often be used by the
    'twistd' command.
    zA short string naming this Twisted plugin, for example 'web' or 'pencil'. This name will be used as the subcommand of 'twistd'.zLA brief summary of the features provided by this Twisted application plugin.zcA C{twisted.python.usage.Options} subclass defining the configuration options for this application.c��y)a
        Create and return an object providing
        L{twisted.application.service.IService}.

        @param options: A mapping (typically a C{dict} or
        L{twisted.python.usage.Options} instance) of configuration
        options to desired configuration values.
        N�)�optionss �=/usr/lib/python3/dist-packages/twisted/application/service.py�makeServicezIServiceMaker.makeService4���N)	�__name__�
__module__�__qualname__�__doc__r�tapname�descriptionrrrrrrrs@����	J��G�
�	&��K�
�	6��G�
rrc�6�eZdZdZd�Zed��Zed��Zy)�ServiceMakerzO
    Utility class to simplify the definition of L{IServiceMaker} plugins.
    c�<�||_||_||_||_y�N)�name�modulerr)�selfrrrrs     r�__init__zServiceMaker.__init__Es����	����&�����rc�@�t|j�jSr)r
r�Options�r s rrzServiceMaker.optionsKs������$�,�,�,rc�@�t|j�jSr)r
rrr$s rrzServiceMaker.makeServiceOs������$�0�0�0rN)rrrrr!�propertyrrrrrrr?s4�����-��-��1��1rrc�d�eZdZdZed�Zed�Zed�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
y)�IServicezS
    A service.

    Run start-up and shut-down code at the appropriate times.
    z5A C{str} which is the name of the service or C{None}.z<A C{boolean} which indicates whether the service is running.z8An C{IServiceCollection} which is the parent or C{None}.c��y)z�
        Set the name of the service.

        @type name: C{str}
        @raise RuntimeError: Raised if the service already has a parent.
        Nr�rs r�setNamezIService.setNamearrc��y)ax
        Set the parent of the service.  This method is responsible for setting
        the C{parent} attribute on this service (the child service).

        @type parent: L{IServiceCollection}
        @raise RuntimeError: Raised if the service already has a parent
            or if the service has a name and the parent already has a child
            by that name.
        Nr)�parents r�setServiceParentzIService.setServiceParentirrc��y)a�
        Use this API to remove an L{IService} from an L{IServiceCollection}.

        This method is used symmetrically with L{setServiceParent} in that it
        sets the C{parent} attribute on the child.

        @rtype: L{Deferred<defer.Deferred>}
        @return: a L{Deferred<defer.Deferred>} which is triggered when the
            service has finished shutting down. If shutting down is immediate,
            a value can be returned (usually, L{None}).
        Nrrrr�disownServiceParentzIService.disownServiceParenttrrc��y)z$
        Start the service.
        Nrrrr�startServicezIService.startService�rrc��y)a"
        Stop the service.

        @rtype: L{Deferred<defer.Deferred>}
        @return: a L{Deferred<defer.Deferred>} which is triggered when the
            service has finished shutting down. If shutting down is immediate,
            a value can be returned (usually, L{None}).
        Nrrrr�stopServicezIService.stopService�rrc��y)z�
        Do preparation work for starting the service.

        Here things which should be done before changing directory,
        root or shedding privileges are done.
        Nrrrr�privilegedStartServicezIService.privilegedStartService�rrN)rrrrrr�runningr-r+r.r0r2r4r6rrrr(r(TsH����L�M�D��V�W�G�
�Q�
R�F��	���
�rr(c�F�eZdZdZdZdZdZd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
y)�Servicez�
    Base class for services.

    Most services should inherit from this class. It handles the
    book-keeping responsibilities of starting and stopping, as well
    as not serializing this book-keeping information.
    rNc�H�|jj�}d|vr|d=|S)Nr7)�__dict__�copy)r �dicts  r�__getstate__zService.__getstate__�s(���}�}�!�!�#������Y���rc�@�|j�td��||_y)Nz%cannot change name when parent exists)r-�RuntimeErrorr�r rs  rr+zService.setName�s���;�;�"��F�G�G���	rc��|j�|j�t||�}||_|jj|�yr)r-r0�IServiceCollection�
addService)r r-s  rr.zService.setServiceParent�s=���;�;�"��$�$�&�#�F�F�3����������t�$rc�J�|jj|�}d|_|Sr)r-�
removeService)r �ds  rr0zService.disownServiceParent�s"���K�K�%�%�d�+������rc��yrrr$s rr6zService.privilegedStartService�s��rc��d|_y)N��r7r$s rr2zService.startService��	����rc��d|_y)NrrKr$s rr4zService.stopService�rLr)rrrrr7rr-r>r+r.r0r6r2r4rrrr9r9�s;����G��D�
�F���
%��

��rr9c�(�eZdZdZd�Zd�Zd�Zd�Zy)rCz�
    Collection of services.

    Contain several services, and manage their start-up/shut-down.
    Services can be accessed by name if they have a name, and it
    is always possible to iterate over them.
    c��y)z�
        Get the child service with a given name.

        @type name: C{str}
        @rtype: L{IService}
        @raise KeyError: Raised if the service has no child with the
            given name.
        Nrr*s r�getServiceNamedz"IServiceCollection.getServiceNamed�rrc��y)z:
        Get an iterator over all child services.
        Nrrrr�__iter__zIServiceCollection.__iter__�rrc��y)a
        Add a child service.

        Only implementations of L{IService.setServiceParent} should use this
        method.

        @type service: L{IService}
        @raise RuntimeError: Raised if the service has a child with
            the given name.
        Nr��services rrDzIServiceCollection.addService�rrc��y)a�
        Remove a child service.

        Only implementations of L{IService.disownServiceParent} should
        use this method.

        @type service: L{IService}
        @raise ValueError: Raised if the given service is not a child.
        @rtype: L{Deferred<defer.Deferred>}
        @return: a L{Deferred<defer.Deferred>} which is triggered when the
            service has finished shutting down. If shutting down is immediate,
            a value can be returned (usually, L{None}).
        NrrTs rrFz IServiceCollection.removeService�rrN)rrrrrPrRrDrFrrrrCrC�s�����

�
rrCc�@�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zy
)�MultiServicea
    Straightforward Service Container.

    Hold a collection of services, and manage them in a simplistic
    way. No service will wait for another, but this object itself
    will not finish shutting down until all of its child services
    will finish.
    c�.�g|_i|_d|_yr)�services�
namedServicesr-r$s rr!zMultiService.__init__s����
������rc�\�tj|�|D]}|j��yr)r9r6�r rUs  rr6z#MultiService.privilegedStartServices+���&�&�t�,��	-�G��*�*�,�	-rc�\�tj|�|D]}|j��yr)r9r2r]s  rr2zMultiService.startServices+�����T�"��	#�G�� � �"�	#rc��tj|�g}t|�}|j�|D]0}|j	tj|j���2tj|�Sr)r9r4�list�reverse�appendr�
maybeDeferred�DeferredList)r �lrZrUs    rr4zMultiService.stopServicesg�����D�!�����:�������	?�G�
�H�H�U�(�(��)<�)<�=�>�	?��!�!�!�$�$rc� �|j|Sr)r[rAs  rrPzMultiService.getServiceNameds���!�!�$�'�'rc�,�t|j�Sr)�iterrZr$s rrRzMultiService.__iter__"s���D�M�M�"�"rc�>�|j�I|j|jvrtd|jz��||j|j<|jj	|�|j
r!|j
�|j�yy)Nz,cannot have two services with same name '%s')rr[r@rZrbr7r6r2r]s  rrDzMultiService.addService%s����<�<�#��|�|�t�1�1�1�"�E����T���07�D���w�|�|�,��
�
���W�%��<�<��*�*�,�� � �"�rc��|jr|j|j=|jj|�|jr|j�Syr)rr[rZ�remover7r4r]s  rrFzMultiService.removeService2sH���<�<��"�"�7�<�<�0��
�
���W�%��<�<��&�&�(�(�rN)rrrrr!r6r2r4rPrRrDrFrrrrXrX�s/����
-�
#�
%�(�#�#�	rrXc�@�eZdZdZed�Zed�Zed�Zy)�IProcessza
    Process running parameters.

    Represents parameters for how processes should be run.
    zv
        A C{str} giving the name the process should have in ps (or L{None}
        to leave the name alone).
        z{
        An C{int} giving the user id as which the process should run (or
        L{None} to leave the UID alone).
        z|
        An C{int} giving the group id as which the process should run (or
        L{None} to leave the GID alone).
        N)rrrrr�processName�uid�gidrrrrmrm>s:����	��K��	��C��	��Crrmc��eZdZdZdZdd�Zy)�Processz�
    Process running parameters.

    Sets up uid/gid in the constructor, and has a default
    of L{None} as C{processName}.
    Nc� �||_||_y)a=
        Set uid and gid.

        @param uid: The user ID as whom to execute the process.  If
            this is L{None}, no attempt will be made to change the UID.

        @param gid: The group ID as whom to execute the process.  If
            this is L{None}, no attempt will be made to change the GID.
        N)rorp)r rorps   rr!zProcess.__init__fs�������r�NN)rrrrrnr!rrrrrrr[s����K�rrrNc���tj�}t�t||�t	j
||�g}|D]}|j
|d���t|�j|�|S)a
    Return a compound class.

    Return an object supporting the L{IService}, L{IServiceCollection},
    L{IProcess} and L{sob.IPersistable} interfaces, with the given
    parameters. Always access the return value by explicit casting to
    one of the interfaces.
    rJ)�ignoreClass)	r	�
ComponentizedrXrrr�
Persistent�addComponentr(r+)rrorp�ret�availableComponents�comps      r�Applicationr}tsm���
"�
"�
$�C�'�>�7�3��+<�c�n�n�S�RV�>W�X��#�.������1��-�.��S�M���$���Jrc�l�|dk(rtj|d�}|Stj||�}|S)a`
    Load Application from a given file.

    The serialization format it was saved in should be given as
    C{kind}, and is one of C{pickle}, C{source}, C{xml} or C{python}. If
    C{passphrase} is given, the application was encrypted with the
    given passphrase.

    @type filename: C{str}
    @type kind: C{str}
    @type passphrase: C{str}
    �python�application)r�loadValueFromFile�load)�filename�kind�
passphraser�s    r�loadApplicationr��s>���x���+�+�H�m�D�����h�h�x��.���r)	rr(r9rCrXrmrrr}r�rtr)r�zope.interfacerrr�twisted.internetr�twisted.persistedr�twisted.pluginr�twisted.pythonr	�twisted.python.reflectr
rrr(r9rCrXrmrrr}r��__all__rrr�<module>r�s���

�=�<�"�!�"�%�+�!�I�!�H
�W�m�$�1�1�%�1�(B�y�B�J
�X��+�+��+�\1��1�h
�
� �>�7�>�!�>�B�y��:
�X������0�$�(
�r

Zerion Mini Shell 1.0