�ɲɾ�����ӯ�����һ��ˣ��������С���˴��ͣ�������P���ҹ��ñ˽��ά�Բ��������˸߸ԣ�������ơ��ҹ��ñ�����ά�Բ���ˡ���˳^�ӣ������ӡ�
���ͯj�ӣ��ƺ���ӣ�
? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!PK \;1]b\ \ _wrappers/_glib.pynu [ # -*- coding: utf-8 -*-
# slip._wrappers._glib -- abstract (some) differences between glib and
# gi.repository.GLib
#
# Copyright © 2012, 2015 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Authors:
# Nils Philippsen
"""This module lets some other slip modules cooperate with either the glib
or the gi.repository.GLib modules."""
from __future__ import absolute_import
import sys
__all__ = ['MainLoop', 'source_remove', 'timeout_add']
_self = sys.modules[__name__]
_mod = None
while _mod is None:
if 'gi.repository.GLib' in sys.modules:
_mod = sys.modules['gi.repository.GLib']
elif 'glib' in sys.modules:
_mod = sys.modules['glib']
# if not yet imported, try to import glib first, then
# gi.repository.GLib ...
if _mod is None:
try:
import glib
except ImportError:
import gi.repository.GLib
# ... then repeat.
for what in __all__:
if what not in dir(_self):
setattr(_self, what, getattr(_mod, what))
PK \;1]2{q q 3 _wrappers/__pycache__/__init__.cpython-36.opt-1.pycnu [ 3
uAc @ s d S )N r r r /usr/lib/python3.6/__init__.py s PK \;1]t5UK 0 _wrappers/__pycache__/_glib.cpython-36.opt-1.pycnu [ 3
uAc\ @ s d Z ddlmZ ddlZdddgZeje ZdZxhedkrdejkrPejd Zndejkrdejd Zedkr2yddl Z W q2 e
k
r ddlZY q2X q2W x*eD ]"Z
e
eekreee
eee
qW dS ) zjThis module lets some other slip modules cooperate with either the glib
or the gi.repository.GLib modules. )absolute_importNZMainLoopZ
source_removeZtimeout_addzgi.repository.GLibglib)__doc__Z
__future__r sys__all__modules__name___selfZ_modr ImportErrorZgi.repository.GLibZgiZwhatdirsetattrgetattr r r /usr/lib/python3.6/_glib.py s$
PK \;1]t5UK * _wrappers/__pycache__/_glib.cpython-36.pycnu [ 3
uAc\ @ s d Z ddlmZ ddlZdddgZeje ZdZxhedkrdejkrPejd Zndejkrdejd Zedkr2yddl Z W q2 e
k
r ddlZY q2X q2W x*eD ]"Z
e
eekreee
eee
qW dS ) zjThis module lets some other slip modules cooperate with either the glib
or the gi.repository.GLib modules. )absolute_importNZMainLoopZ
source_removeZtimeout_addzgi.repository.GLibglib)__doc__Z
__future__r sys__all__modules__name___selfZ_modr ImportErrorZgi.repository.GLibZgiZwhatdirsetattrgetattr r r /usr/lib/python3.6/_glib.py s$
PK \;1]2{q q - _wrappers/__pycache__/__init__.cpython-36.pycnu [ 3
uAc @ s d S )N r r r /usr/lib/python3.6/__init__.py s PK \;1] _wrappers/__init__.pynu [ PK \;1] dbus/introspection.pynu [ # -*- coding: utf-8 -*-
# slip.dbus.introspection -- access dbus introspection data
#
# Copyright © 2011 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Authors:
# Nils Philippsen
"""Classes and functions to easily access DBus introspection data."""
from __future__ import absolute_import
from xml.etree.ElementTree import ElementTree
from io import StringIO
from six import with_metaclass
class IElemMeta(type):
"""Metaclass for introspection elements.
Sets elemname class member automatically from class name if not set
explicitly. Registers classes for their element names."""
elemnames_to_classes = {}
@classmethod
def clsname_to_elemname(cls, clsname):
elemname = ""
for c in clsname:
c_lower = c.lower()
if c_lower != c:
if len(elemname):
elemname += "_"
elemname += c_lower
return elemname
def __new__(cls, name, bases, dct):
if name == "IElem":
return type.__new__(cls, name, bases, dct)
if 'elemname' not in dct:
if not name.startswith("IElem"):
raise TypeError(
"Class '%s' needs to set elemname (or be called "
"'IElem...'))" % name)
dct['elemname'] = IElemMeta.clsname_to_elemname(name[5:])
elemname = dct['elemname']
if elemname in IElemMeta.elemnames_to_classes:
raise TypeError(
"Class '%s' tries to register duplicate elemname '%s'" %
(name, elemname))
kls = type.__new__(cls, name, bases, dct)
IElemMeta.elemnames_to_classes[elemname] = kls
return kls
class IElem(with_metaclass(IElemMeta, object)):
"""Base class for introspection elements."""
def __new__(cls, elem, parent=None):
kls = IElemMeta.elemnames_to_classes.get(
elem.tag, IElemMeta.elemnames_to_classes[None])
return super(IElem, cls).__new__(kls, elem, parent)
def __init__(self, elem, parent=None):
self.elem = elem
self.parent = parent
self.child_elements = [IElem(c, parent=self) for c in elem]
def __str__(self):
s = "%s %r" % (self.elemname if self.elemname else "unknown:%s" %
self.elem.tag, self.attrib)
for c in self.child_elements:
for cc in str(c).split("\n"):
s += "\n %s" % (cc)
return s
@property
def attrib(self):
return self.elem.attrib
class IElemUnknown(IElem):
"""Catch-all for unknown introspection elements."""
elemname = None
class IElemNameMixin(object):
"""Mixin for introspection elements with names."""
@property
def name(self):
return self.attrib['name']
class IElemNode(IElem, IElemNameMixin):
"""Introspection node."""
def __init__(self, elem, parent=None):
super(IElemNode, self).__init__(elem, parent)
self.child_nodes = [
c for c in self.child_elements if isinstance(c, IElemNode)]
class IElemInterface(IElem):
"""Introspection interface."""
class IElemMethod(IElem):
"""Introspection interface method."""
class IElemArg(IElem):
"""Introspection method argument."""
class IElemSignal(IElem, IElemNameMixin):
"""Introspection interface signal."""
def introspect(string_or_file):
tree = ElementTree()
# assume string if read() method doesn't exist, works for string, unicode,
# dbus.String
if not hasattr(string_or_file, "read"):
string_or_file = StringIO(string_or_file)
xml_root = tree.parse(string_or_file)
elem_root = IElem(xml_root)
return elem_root
PK \;1]!+ dbus/service.pynu [ # -*- coding: utf-8 -*-
# slip.dbus.service -- convenience functions for using dbus-activated
# services
#
# Copyright © 2008, 2009, 2015 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Authors:
# Nils Philippsen
"This module contains convenience functions for using dbus-activated services."
from __future__ import absolute_import
import dbus
import dbus.service
from six import with_metaclass
from .._wrappers import _glib as GLib
from . import polkit
__all__ = ["Object", "InterfaceType", "set_mainloop"]
__mainloop__ = None
def __glib_quit_cb__():
global __mainloop__
# assume a Glib mainloop
__mainloop__.quit()
__quit_cb__ = __glib_quit_cb__
def set_mainloop(mainloop):
global __mainloop__
__mainloop__ = mainloop
def set_quit_cb(quit_cb):
global __quit_cb__
__quit_cb__ = quit_cb
def quit_cb():
global __quit_cb__
__quit_cb__()
SENDER_KEYWORD = "__slip_dbus_service_sender__"
ASYNC_CALLBACKS = ("__slip_dbus_service_reply_cb__",
"__slip_dbus_service_error_cb__")
def wrap_method(method):
global SENDER_KEYWORD
global ASYNC_CALLBACKS
if method._dbus_sender_keyword is not None:
sender_keyword = method._dbus_sender_keyword
hide_sender_keyword = False
else:
sender_keyword = SENDER_KEYWORD
hide_sender_keyword = True
if method._dbus_async_callbacks is not None:
async_callbacks = method._dbus_async_callbacks
method_is_async = True
else:
async_callbacks = ASYNC_CALLBACKS
method_is_async = False
hide_async_callbacks = not method_is_async
def wrapped_method(self, *p, **k):
sender = k.get(sender_keyword)
if sender is not None:
# i.e. called over the bus, not locally
reply_cb = k[async_callbacks[0]]
error_cb = k[async_callbacks[1]]
if hide_sender_keyword:
del k[sender_keyword]
if hide_async_callbacks:
del k[async_callbacks[0]]
del k[async_callbacks[1]]
self.sender_seen(sender)
action_id = getattr(method, "_slip_polkit_auth_required",
getattr(self, "default_polkit_auth_required",
None))
if sender is not None and action_id:
def reply_handler(is_auth):
if is_auth:
if method_is_async:
# k contains async callbacks, simply pass on reply_cb
# and error_cb
method(self, *p, **k)
else:
# execute the synchronous method ...
error = None
try:
result = method(self, *p, **k)
except Exception as e:
error = e
# ... and call the reply or error callback
if error:
error_cb(error)
else:
# reply_cb((None,)) != reply_cb()
if result is None:
reply_cb()
else:
reply_cb(result)
else:
error_cb(polkit.NotAuthorizedException(action_id))
self.timeout_restart()
def error_handler(error):
error_cb(error)
self.timeout_restart()
polkit.IsSystemBusNameAuthorizedAsync(
sender, action_id,
reply_handler=reply_handler, error_handler=error_handler)
else:
# no action id, or run locally, no need to do anything fancy
retval = method(self, *p, **k)
self.timeout_restart()
return retval
for attr in (x for x in dir(method) if x[:6] == "_dbus_"):
if attr == "_dbus_sender_keyword":
wrapped_method._dbus_sender_keyword = sender_keyword
elif attr == "_dbus_async_callbacks":
wrapped_method._dbus_async_callbacks = async_callbacks
else:
setattr(wrapped_method, attr, getattr(method, attr))
# delattr (method, attr)
wrapped_method.__name__ = method.__name__
return wrapped_method
class InterfaceType(dbus.service.InterfaceType):
def __new__(cls, name, bases, dct):
for (attrname, attr) in dct.items():
if getattr(attr, "_dbus_is_method", False):
dct[attrname] = wrap_method(attr)
return super(InterfaceType, cls).__new__(cls, name, bases, dct)
class Object(with_metaclass(InterfaceType, dbus.service.Object)):
# timeout & persistence
persistent = False
default_duration = 5
duration = default_duration
current_source = None
senders = set()
connections_senders = {}
connections_smobjs = {}
# PolicyKit
default_polkit_auth_required = None
def __init__(
self, conn=None, object_path=None, bus_name=None, persistent=None):
super(Object, self).__init__(conn, object_path, bus_name)
if persistent is None:
self.persistent = self.__class__.persistent
else:
self.persistent = persistent
def _timeout_cb(self):
if not self.persistent and len(Object.senders) == 0:
quit_cb()
return False
Object.current_source = None
Object.duration = self.default_duration
return False
def _name_owner_changed(self, name, old_owner, new_owner):
conn = self.connection
if not new_owner and (old_owner, conn) in Object.senders:
Object.senders.remove((old_owner, conn))
Object.connections_senders[conn].remove(old_owner)
if len(Object.connections_senders[conn]) == 0:
Object.connections_smobjs[conn].remove()
del Object.connections_senders[conn]
del Object.connections_smobjs[conn]
if not self.persistent and len(Object.senders) == 0 and \
Object.current_source is None:
quit_cb()
def timeout_restart(self, duration=None):
if not duration:
duration = self.__class__.default_duration
if not Object.duration or duration > Object.duration:
Object.duration = duration
if not self.persistent or len(Object.senders) == 0:
if Object.current_source:
GLib.source_remove(Object.current_source)
Object.current_source = \
GLib.timeout_add(Object.duration * 1000,
self._timeout_cb)
def sender_seen(self, sender):
if (sender, self.connection) not in Object.senders:
Object.senders.add((sender, self.connection))
if self.connection not in Object.connections_senders:
Object.connections_senders[self.connection] = set()
Object.connections_smobjs[self.connection] = \
self.connection.add_signal_receiver(
handler_function=self._name_owner_changed,
signal_name='NameOwnerChanged',
dbus_interface='org.freedesktop.DBus',
arg1=sender)
Object.connections_senders[self.connection].add(sender)
PK \;1]$:Y Y dbus/bus.pynu [ # -*- coding: utf-8 -*-
# slip.dbus.bus -- augmented dbus buses
#
# Copyright © 2009, 2011 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Authors:
# Nils Philippsen
"""This module contains functions which create monkey-patched/augmented D-Bus
buses."""
from __future__ import absolute_import
import dbus
from . import proxies
from . import constants
for name in ("Bus", "SystemBus", "SessionBus", "StarterBus"):
exec(
"""def %(name)s(*args, **kwargs):
busobj = dbus.%(name)s(*args, **kwargs)
busobj.ProxyObjectClass = proxies.ProxyObject
busobj.default_timeout = %(default_timeout)s
return busobj
""" % {
"name": name, "modname": __name__,
"default_timeout": constants.method_call_no_timeout})
PK \;1]@ ) dbus/__pycache__/constants.cpython-36.pycnu [ 3
uAc @ s d Z dZdS )z*This module contains some constant values.ig @@Ng`Mb@A)__doc__Zmethod_call_no_timeout r r /usr/lib/python3.6/constants.py s PK \;1]rbb b . dbus/__pycache__/mainloop.cpython-36.opt-1.pycnu [ 3
uAc#
@ s@ d Z ddlmZ d
ZG dd deZG dd deZdd Zd S )zVThis module contains mainloop wrappers.
Currently only glib main loops are supported. )absolute_importMainLoopset_typec sX e Zd ZdZdZ fddZedd Zdd Zd d
Z dd Z
d
d Zdd Z Z
S )r a An abstract main loop wrapper class and factory.
Use MainLoop() to get a main loop wrapper object for a main loop type
previously registered with set_type(). Defaults to glib main loops.
Actual main loop wrapper classes are derived from this class.Nc s. t jd krt jd tt | jt jf||S )Nglib)r Z_mainloop_classr super__new___MainLoop__mainloop_class)clsargskwargs) __class__ /usr/lib/python3.6/mainloop.pyr * s
zMainLoop.__new__c C sH t jdk rtddti}||kr.|| t _ntd|dj|f dS )zxSet a main loop type for non-blocking interfaces.
mltype: "glib" (currently only glib main loops are supported)Nz(The main loop type can only be set once.r z0'%s' is not one of the valid main loop types:
%sz, )r r RuntimeErrorGlibMainLoop
ValueErrorjoin)r mltypeZ
ml_type_classr
r
r r 1 s
zMainLoop.set_typec C s
t dS )z$Returns if there are pending events.N)NotImplementedError)selfr
r
r pendingC s zMainLoop.pendingc C s
t dS )z Iterates over one pending event.N)r )r r
r
r iterateH s zMainLoop.iteratec C s x| j r| j qW dS )z!Iterates over all pending events.N)r r )r r
r
r iterate_over_pending_eventsM s
z$MainLoop.iterate_over_pending_eventsc C s
t dS )zRuns the main loop.N)r )r r
r
r runS s zMainLoop.runc C s
t dS )zQuits the main loop.N)r )r r
r
r quitX s z
MainLoop.quit)__name__
__module____qualname____doc__r r classmethodr r r r r r
__classcell__r
r
)r r r s c @ s e Zd Zdd ZdS )r c C sF ddl m} |j }|j }|| _|j| _|j| _|j| _|j | _ d S )N )_glib)
Z _wrappersr" r Zget_contextZ _mainloopr Z iterationr r r )r r" ZmlZctxr
r
r __init__` s zGlibMainLoop.__init__N)r r r r# r
r
r
r r ^ s r c C s$ ddl m} |dt tj| dS )zSet a main loop type for non-blocking interfaces.
mltype: "glib" (currently only glib main loops are supported)
Deprecated, use MainLoop.set_type() instead.r )warnzuse MainLoop.set_type() insteadN)warningsr$ DeprecationWarningr r )r r$ r
r
r r l s
N)r r )r Z
__future__r __all__objectr r r r
r
r
r s
>PK \;1])* . dbus/__pycache__/__init__.cpython-36.opt-1.pycnu [ 3
uAc @ s` d dl mZ ddlmZ ddlmZmZmZ ddlmZ ddlmZ ddlm Z ddlm
Z
d S )
)absolute_import )bus)
SessionBus SystemBus
StarterBus)proxies)service)polkit)mainloopN)Z
__future__r r r r r r r r
r r
r
/usr/lib/python3.6/__init__.py s PK \;1]x ' dbus/__pycache__/service.cpython-36.pycnu [ 3
uAc @ s d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl
mZ d d
dgZda
dd
Zeadd Zdd Zdd Zdadadd ZG dd
d
ejjZG dd d eeejjZdS )zMThis module contains convenience functions for using dbus-activated services. )absolute_importN)with_metaclass )_glib )polkitObject
InterfaceTypeset_mainloopc C s t j d S )N)__mainloop__quit r
r
/usr/lib/python3.6/service.py__glib_quit_cb__) s r c C s | a d S )N)r )Zmainloopr
r
r r
4 s c C s | a d S )N)__quit_cb__)quit_cbr
r
r set_quit_cb9 s r c C s
t d S )N)r r
r
r
r r > s r Z__slip_dbus_service_sender____slip_dbus_service_reply_cb____slip_dbus_service_error_cb__c s j d k rj dntdjd k r4j dnt d fdd}xLdd tD D ]6}|dkr|_ ql|dkr |_qlt||t| qlW j|_|S ) NFTc s j }|d k rVd d r4= rLd = d = j| t dtdd |d k r r
fdd}fdd}tj| ||d n f}j |S d S )
Nr r Z_slip_polkit_auth_requireddefault_polkit_auth_requiredc s | rrf qd }yf}W n& t k
rX } z
|}W Y d d }~X nX |rh| q|d krx q| ntj j d S )N) Exceptionr ZNotAuthorizedExceptiontimeout_restart)Zis_autherrorresulte) action_iderror_cbkmethodmethod_is_asyncpreply_cbselfr
r
reply_handlerq s
z:wrap_method..wrapped_method..reply_handlerc s | j d S )N)r )r )r r" r
r
error_handler s z:wrap_method..wrapped_method..error_handler)r# r$ )getsender_seengetattrr ZIsSystemBusNameAuthorizedAsyncr )r" r r senderr# r$ Zretval)async_callbackshide_async_callbackshide_sender_keywordr r sender_keyword)r r r r r! r" r wrapped_method[ s,
"z#wrap_method..wrapped_methodc s s" | ]}|d d dkr|V qd S )N Z_dbus_r
).0xr
r
r