o t3b(F@sdZdZddlZddlZddlmZmZmZmZm Z m Z m Z m Z m Z mZmZmZmZmZmZmZmZmZmZmZmZmZmZddlmZddlmZddl m!Z!ddl"m#Z#d eeefZ$ d Z%e&d Z'Gd d d e(Z)GdddeZ*dS)) BusConnectionreStructuredTextN)BUS_DAEMON_IFACEBUS_DAEMON_NAMEBUS_DAEMON_PATH BUS_SESSION BUS_STARTER BUS_SYSTEM DBUS_START_REPLY_ALREADY_RUNNINGDBUS_START_REPLY_SUCCESSNAME_FLAG_ALLOW_REPLACEMENTNAME_FLAG_DO_NOT_QUEUENAME_FLAG_REPLACE_EXISTINGRELEASE_NAME_REPLY_NON_EXISTENTRELEASE_NAME_REPLY_NOT_OWNERRELEASE_NAME_REPLY_RELEASED REQUEST_NAME_REPLY_ALREADY_OWNERREQUEST_NAME_REPLY_EXISTSREQUEST_NAME_REPLY_IN_QUEUE REQUEST_NAME_REPLY_PRIMARY_OWNERvalidate_bus_namevalidate_error_namevalidate_interface_namevalidate_member_namevalidate_object_path) Connection) DBusException)HANDLER_RESULT_NOT_YET_HANDLED)is_py2zWtype='signal',sender='%s',interface='%s',member='NameOwnerChanged',path='%s',arg0='%%s'z)org.freedesktop.DBus.Error.NameHasNoOwnerzdbus.busc@s eZdZdZddZddZdS)NameOwnerWatch)_match _pending_callc srtfdd}fdd}|j|dtttd|_i}tr%d|d<|jtttd d f|fi||_dS) Ncs |dSN)owned old_owner new_owner)callbackr#*/usr/lib/python3/dist-packages/dbus/bus.py signal_cbBs z*NameOwnerWatch.__init__..signal_cbcs<|tkr ddSttjd|j|dfddS)NzGetNameOwner(%s) failed:)exc_info) get_dbus_name_NAME_HAS_NO_OWNERlogging basicConfig_loggerdebug __class__)ebus_namer'r#r(error_cbEs    z)NameOwnerWatch.__init__..error_cbNameOwnerChanged)arg0T utf8_strings GetNameOwners) radd_signal_receiverrrrr r call_asyncr!)selfbus_connr5r'r)r6keywordsr#r4r(__init__?s,  zNameOwnerWatch.__init__cCs8|jdur |j|jdur|jd|_d|_dSr")r remover!cancel)r>r#r#r(rC^s     zNameOwnerWatch.cancelN)__name__ __module__ __qualname__ __slots__rArCr#r#r#r(r<s rcseZdZdZeZ eZ eZ e Z e Z edfddZ   d*fdd ZddZd d Z d+d dZddZd,ddZd,ddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)ZZ S)-rzxA connection to a D-Bus daemon that implements the ``org.freedesktop.DBus`` pseudo-service. :Since: 0.81.0 NcCs$|j||d}t|_i|_ |S)N)mainloop) _new_for_busweakrefWeakValueDictionary _bus_names_signal_sender_matches)clsaddress_or_typerHbusr#r#r(__new__{s  zBusConnection.__new__c  s|dd}|dur!|durtd|}ddlm}|dtddtt|j|||||fi||durV|tkrV|ddd krHfd d } nj } | || } | |j <| t S) N named_service3bus_name and named_service cannot both be specifiedrwarnzrPassing the named_service parameter to add_signal_receiver by name is deprecated: please use positional parameters stacklevel:cs|dkr dSdS)Nr*)rB)r&matchr#r(r's z3BusConnection.add_signal_receiver..callback)pop TypeErrorwarningsrUDeprecationWarningsuperrr<rset_sender_name_ownerwatch_name_ownerrMadd_match_stringstr) r>handler_function signal_namedbus_interfacer5pathr@rRrUr'watchr2r[r(r<s.     z!BusConnection.add_signal_receivercCs4|t||j|d}|dur|dSdSr") remove_match_string_non_blockingrerMr]rC)r>r\rjr#r#r(_clean_up_signal_matchs  z$BusConnection._clean_up_signal_matchc Csx|dur:|dddkr:|tkr:z||WSty9}z|tkr%||||WYd}~Sd}~ww|S)NrYrZ)rget_name_ownerrr,r-start_service_by_name)r>r5r3r#r#r(activate_name_owners   z!BusConnection.activate_name_ownerTFcKs||r||dd}|dur'|durtdddlm}|dtdd|}|r4td d ||j|||||d S) aJReturn a local proxy for the given remote object. Method calls on the proxy are translated into method calls on the remote object. :Parameters: `bus_name` : str A bus name (either the unique name or a well-known name) of the application owning the object. The keyword argument named_service is a deprecated alias for this. `object_path` : str The object path of the desired object `introspect` : bool If true (default), attempt to introspect the remote object to find out supported methods and their signatures `follow_name_owner_changes` : bool If the object path is a well-known name and this parameter is false (default), resolve the well-known name to the unique name of its current owner and bind to that instead; if the ownership of the well-known name changes in future, keep communicating with the original owner. This is necessary if the D-Bus API used is stateful. If the object path is a well-known name and this parameter is true, whenever the well-known name changes ownership in future, bind to the new owner, if any. If the given object path is a unique name, this parameter has no effect. :Returns: a `dbus.proxies.ProxyObject` :Raises `DBusException`: if resolving the well-known name to a unique name fails rRNrSrrTziPassing the named_service parameter to get_object by name is deprecated: please use positional parametersrVrWz4get_object does not take these keyword arguments: %sz, ) introspectfollow_name_owner_changes) _require_main_loopr]r^r_rUr`joinkeysProxyObjectClass)r>r5 object_pathrqrrkwargsrRrUr#r#r( get_objects&$    zBusConnection.get_objectcCst||tttdd|fS)zGet the numeric uid of the process owning the given bus name. :Parameters: `bus_name` : str A bus name, either unique or well-known :Returns: a `dbus.UInt32` :Since: 0.80.0 GetConnectionUnixUserr;r call_blockingrrrr>r5r#r#r( get_unix_users  zBusConnection.get_unix_userrc Cs$t|d|tttdd||ffS)a?Start a service which will implement the given bus name on this Bus. :Parameters: `bus_name` : str The well-known bus name to be activated. `flags` : dbus.UInt32 Flags to pass to StartServiceByName (currently none are defined) :Returns: A tuple of 2 elements. The first is always True, the second is either START_REPLY_SUCCESS or START_REPLY_ALREADY_RUNNING. :Raises `DBusException`: if the service could not be started. :Since: 0.80.0 TStartServiceByNamesur{)r>r5flagsr#r#r(ros  z#BusConnection.start_service_by_namec Cs$t|dd|tttdd||fS)aRequest a bus name. :Parameters: `name` : str The well-known name to be requested `flags` : dbus.UInt32 A bitwise-OR of 0 or more of the flags `NAME_FLAG_ALLOW_REPLACEMENT`, `NAME_FLAG_REPLACE_EXISTING` and `NAME_FLAG_DO_NOT_QUEUE` :Returns: `REQUEST_NAME_REPLY_PRIMARY_OWNER`, `REQUEST_NAME_REPLY_IN_QUEUE`, `REQUEST_NAME_REPLY_EXISTS` or `REQUEST_NAME_REPLY_ALREADY_OWNER` :Raises `DBusException`: if the bus daemon cannot be contacted or returns an error. F allow_unique RequestNamerr{)r>namerr#r#r( request_names zBusConnection.request_namecCs"t|dd|tttdd|fS)asRelease a bus name. :Parameters: `name` : str The well-known name to be released :Returns: `RELEASE_NAME_REPLY_RELEASED`, `RELEASE_NAME_REPLY_NON_EXISTENT` or `RELEASE_NAME_REPLY_NOT_OWNER` :Raises `DBusException`: if the bus daemon cannot be contacted or returns an error. Fr ReleaseNamer;r{)r>rr#r#r( release_name3s zBusConnection.release_namecC,i}trd|d<|jtttdddfi|S)zReturn a list of all currently-owned names on the bus. :Returns: a dbus.Array of dbus.UTF8String :Since: 0.81.0 Tr9 ListNamesr*r#rr|rrrr>r@r#r#r( list_namesDzBusConnection.list_namescCr)zReturn a list of all names that can be activated on the bus. :Returns: a dbus.Array of dbus.UTF8String :Since: 0.81.0 Tr9ListActivatableNamesr*r#rrr#r#r(list_activatable_namesQrz$BusConnection.list_activatable_namescCs:i}trd|d<t|dd|jtttdd|ffi|S)zReturn the unique connection name of the primary owner of the given name. :Raises `DBusException`: if the `bus_name` has no owner :Since: 0.81.0 Tr9Frr:r;)rrr|rrr)r>r5r@r#r#r(rn^s zBusConnection.get_name_ownercCs t|||S)aWatch the unique connection name of the primary owner of the given name. `callback` will be called with one argument, which is either the unique connection name, or the empty string (meaning the name is not owned). :Since: 0.81.0 )r)r>r5r'r#r#r(rcms zBusConnection.watch_name_ownerc Cst|tttdd|fS)zReturn True iff the given bus name has an owner on this bus. :Parameters: `bus_name` : str The bus name to look up :Returns: a `bool` NameHasOwnerr;)boolr|rrrr}r#r#r(name_has_ownerys zBusConnection.name_has_ownercC|tttdd|fdS)Arrange for this application to receive messages on the bus that match the given rule. This version will block. :Parameters: `rule` : str The match rule :Raises `DBusException`: on error. :Since: 0.80.0 AddMatchr;Nr|rrrr>ruler#r#r(rd zBusConnection.add_match_stringc C|tttdd|fdddS)=Arrange for this application to receive messages on the bus that match the given rule. This version will not block, but any errors will be ignored. :Parameters: `rule` : str The match rule :Raises `DBusException`: on error. :Since: 0.80.0 rr;Nr=rrrrr#r#r(add_match_string_non_blocking z+BusConnection.add_match_string_non_blockingcCr)r RemoveMatchr;Nrrr#r#r(remove_match_stringrz!BusConnection.remove_match_stringc Cr)rrr;Nrrr#r#r(rlrz.BusConnection.remove_match_string_non_blocking)NNNN)TF)r)!rDrErF__doc__r TYPE_SESSIONr TYPE_SYSTEMr TYPE_STARTERr START_REPLY_SUCCESSr START_REPLY_ALREADY_RUNNINGrQr<rmrpryr~rorrrrrnrcrrdrrrl __classcell__r#r#rkr(rgsB   9       r)+__all__ __docformat__r.rJ_dbus_bindingsrrrrrr r r r r rrrrrrrrrrrrrdbus.connectionrdbus.exceptionsr dbus.lowlevelr dbus._compatr_NAME_OWNER_CHANGE_MATCHr- getLoggerr0objectrrr#r#r#r(s&d    +