ó
æö/Nc           @   s˜  d  Z  d d l m Z d Z d Z d d l Z d d l Z d d l Z d d	 l m	 Z	 d d
 l
 m Z d d l m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z d d l m Z d d l m Z y d d l Z Wn e k
 rd d l  Z n Xd e f d „  ƒ  YZ! d e! f d „  ƒ  YZ" d e! f d „  ƒ  YZ# d e! f d „  ƒ  YZ$ d e j% k r”d d d „  ƒ  YZ& e& ƒ  a' n  d S(   s9   Implementation for dbus.Bus. Not to be imported directly.iÿÿÿÿ(   t
   generatorst   Bust	   SystemBust
   SessionBust
   StarterBust   reStructuredTextN(   t	   print_exc(   t   DBusException(   t   BUS_DAEMON_NAMEt   BUS_DAEMON_PATHt   BUS_DAEMON_IFACEt
   UTF8Stringt   validate_member_namet   validate_interface_namet   validate_bus_namet   validate_object_patht   BUS_SESSIONt
   BUS_SYSTEMt   BUS_STARTERt   DBUS_START_REPLY_SUCCESSt    DBUS_START_REPLY_ALREADY_RUNNING(   t   BusConnection(   t   SignalMessagec           B   s§   e  Z d  Z i  Z e j e d	 d „ Z d „  Z	 d „  Z
 e e
 d	 d	 d ƒ Z e d „ Z e e ƒ Z e d „ Z e e ƒ Z e d „ Z e e ƒ Z d „  Z e Z RS(
   s   A connection to one of three possible standard buses, the SESSION,
    SYSTEM, or STARTER bus. This class manages shared connections to those
    buses.

    If you're trying to subclass `Bus`, you may be better off subclassing
    `BusConnection`, which doesn't have all this magic.
    c         C   s«   | r! | |  j  k r! |  j  | S| t k r6 t } n: | t k rK t } n% | t k r` t } n t d | ƒ ‚ t j	 | | d | ƒ} | | _
 | s§ | |  j  | <n  | S(   sË  Constructor, returning an existing instance where appropriate.

        The returned instance is actually always an instance of `SessionBus`,
        `SystemBus` or `StarterBus`.

        :Parameters:
            `bus_type` : cls.TYPE_SESSION, cls.TYPE_SYSTEM or cls.TYPE_STARTER
                Connect to the appropriate bus
            `private` : bool
                If true, never return an existing shared instance, but instead
                return a private connection.

                :Deprecated: since 0.82.3. Use dbus.bus.BusConnection for
                    private connections.

            `mainloop` : dbus.mainloop.NativeMainLoop
                The main loop to use. The default is to use the default
                main loop if one has been set up, or raise an exception
                if none has been.
        :Changed: in dbus-python 0.80:
            converted from a wrapper around a Connection to a Connection
            subclass.
        s   invalid bus_type %st   mainloop(   t   _shared_instancesR   R   R   R   R   R   t
   ValueErrorR   t   __new__t	   _bus_type(   t   clst   bus_typet   privateR   t   subclasst   bus(    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyR   B   s    				c         C   sK   |  j  } |  j j j | ƒ |  k r4 |  j j | =n  t t |  ƒ j ƒ  d  S(   N(   R   t	   __class__R   t   gett   superR   t   close(   t   selft   t(    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyR$   u   s    	c         C   s   |  S(   sª   Return self, for backwards compatibility with earlier dbus-python
        versions where Bus was not a subclass of Connection.

        :Deprecated: since 0.80.0
        (    (   R%   (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyt   get_connection{   s    s¹   self._connection == self, for backwards
                           compatibility with earlier dbus-python versions
                           where Bus was not a subclass of Connection.c         C   s   t  d |  ƒ S(   s³   Static method that returns a connection to the session bus.

        :Parameters:
            `private` : bool
                If true, do not return a shared connection.
        R   (   R   (   R   (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyt   get_session‡   s    c         C   s   t  d |  ƒ S(   s²   Static method that returns a connection to the system bus.

        :Parameters:
            `private` : bool
                If true, do not return a shared connection.
        R   (   R   (   R   (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyt
   get_system’   s    c         C   s   t  d |  ƒ S(   s³   Static method that returns a connection to the starter bus.

        :Parameters:
            `private` : bool
                If true, do not return a shared connection.
        R   (   R   (   R   (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyt   get_starterž   s    c         C   st   |  j  t k r d } n6 |  j  t k r0 d } n |  j  t k rH d } n d } d |  j j |  j j | t |  ƒ f S(   Nt   sessiont   systemt   starters   unknown bus types   <%s.%s (%s) at %#x>(   R   R   R   R   R!   t
   __module__t   __name__t   id(   R%   t   name(    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyt   __repr__©   s    				N(   R/   R.   t   __doc__R   R   t   TYPE_SESSIONt   Falset   NoneR   R$   R'   t   propertyt   _connectionR(   t   staticmethodR)   R*   R2   t   __str__(    (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyR   7   s    	2							c           B   s   e  Z d  Z e d d „ Z RS(   s   The system-wide message bus.c         C   s   t  j |  t  j d | d | ƒS(   sÆ  Return a connection to the system bus.

        :Parameters:
            `private` : bool
                If true, never return an existing shared instance, but instead
                return a private connection.
            `mainloop` : dbus.mainloop.NativeMainLoop
                The main loop to use. The default is to use the default
                main loop if one has been set up, or raise an exception
                if none has been.
        R   R   (   R   R   t   TYPE_SYSTEM(   R   R   R   (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyR   ½   s    N(   R/   R.   R3   R5   R6   R   (    (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyR   »   s   c           B   s   e  Z d  Z e d d „ Z RS(   s(   The session (current login) message bus.c         C   s   t  j |  t  j d | d | ƒS(   sÇ  Return a connection to the session bus.

        :Parameters:
            `private` : bool
                If true, never return an existing shared instance, but instead
                return a private connection.
            `mainloop` : dbus.mainloop.NativeMainLoop
                The main loop to use. The default is to use the default
                main loop if one has been set up, or raise an exception
                if none has been.
        R   R   (   R   R   R4   (   R   R   R   (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyR   Î   s    N(   R/   R.   R3   R5   R6   R   (    (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyR   Ì   s   c           B   s   e  Z d  Z e d d „ Z RS(   sj   The bus that activated this process (only valid if
    this process was launched by DBus activation).
    c         C   s   t  j |  t  j d | d | ƒS(   sÛ  Return a connection to the bus that activated this process.

        :Parameters:
            `private` : bool
                If true, never return an existing shared instance, but instead
                return a private connection.
            `mainloop` : dbus.mainloop.NativeMainLoop
                The main loop to use. The default is to use the default
                main loop if one has been set up, or raise an exception
                if none has been.
        R   R   (   R   R   t   TYPE_STARTER(   R   R   R   (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyR   á   s    N(   R/   R.   R3   R5   R6   R   (    (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyR   Ý   s   t   DBUS_PYTHON_NO_DEPRECATEDt   _DBusBindingsEmulationc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s0   A partial emulation of the dbus_bindings module.c         C   s   d S(   Ns   _DBusBindingsEmulation()(    (   R%   (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyR:   õ   s    c         C   s   d S(   Ns   _DBusBindingsEmulation()(    (   R%   (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyR2   ÷   s    c         C   s"   d d  l  j } | a t | | ƒ S(   Niÿÿÿÿ(   t   dbus.dbus_bindingst   dbus_bindingst   getattr(   R%   t   attrt   m(    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyt   __getattr__ù   s    (   R/   R.   R3   R:   R2   RD   (    (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyR>   ó   s   		(   s   Buss	   SystemBuss
   SessionBuss
   StarterBus(    ((   R3   t
   __future__R    t   __all__t   __docformat__t   ost   syst   weakreft	   tracebackR   t   dbus.exceptionsR   t   _dbus_bindingsR   R	   R
   R   R   R   R   R   R   R   R   R   R   t   dbus.busR   t   dbus.lowlevelR   t   threadt   ImportErrort   dummy_threadR   R   R   R   t   environR>   R@   (    (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyt   <module>   s.   X„	