313
314
"created", "enabled", "fingerprint",
314
315
"host", "interval", "last_checked_ok",
315
316
"last_enabled", "name", "timeout")
317
318
def timeout_milliseconds(self):
318
319
"Return the 'timeout' attribute in milliseconds"
319
320
return _timedelta_to_milliseconds(self.timeout)
321
322
def extended_timeout_milliseconds(self):
322
323
"Return the 'extended_timeout' attribute in milliseconds"
323
324
return _timedelta_to_milliseconds(self.extended_timeout)
629
631
for name, prop in
630
632
inspect.getmembers(self, self._is_dbus_property))
634
# def _get_dbus_property(self, interface_name, property_name):
635
# """Returns a bound method if one exists which is a D-Bus
636
# property with the specified name and interface.
638
# print("get_property({0!r}, {1!r}".format(interface_name, property_name),file=sys.stderr)
639
# print(dir(self), sys.stderr)
640
# for name in (property_name,
641
# property_name + "_dbus_property"):
642
# prop = getattr(self, name, None)
644
# or not self._is_dbus_property(prop)
645
# or prop._dbus_name != property_name
646
# or (interface_name and prop._dbus_interface
647
# and interface_name != prop._dbus_interface)):
651
# raise DBusPropertyNotFound(self.dbus_object_path + ":"
652
# + interface_name + "."
632
655
def _get_dbus_property(self, interface_name, property_name):
633
656
"""Returns a bound method if one exists which is a D-Bus
634
657
property with the specified name and interface.
636
for name in (property_name,
637
property_name + "_dbus_property"):
638
prop = getattr(self, name, None)
640
or not self._is_dbus_property(prop)
641
or prop._dbus_name != property_name
642
or (interface_name and prop._dbus_interface
643
and interface_name != prop._dbus_interface)):
659
for name, value in inspect.getmembers(self, self._is_dbus_property):
660
if value._dbus_name == property_name and value._dbus_interface == interface_name:
646
663
# No such property
647
664
raise DBusPropertyNotFound(self.dbus_object_path + ":"
648
665
+ interface_name + "."
651
669
@dbus.service.method(dbus.PROPERTIES_IFACE, in_signature="ss",
652
670
out_signature="v")
757
775
return dbus.String(dt.isoformat(),
758
776
variant_level=variant_level)
778
class transitional_clientdbus(DBusObjectWithProperties.__metaclass__):
779
def __new__(mcs, name, bases, attr):
780
for key, old_dbusobj in attr.items():
781
new_interface = getattr(old_dbusobj, "_dbus_interface", "").replace("se.bsnet.fukt.", "se.recompile.")
782
if getattr(old_dbusobj, "_dbus_is_signal", False):
783
unwrappedfunc = dict(zip(old_dbusobj.func_code.co_freevars,
784
old_dbusobj.__closure__))["func"].cell_contents
785
newfunc = types.FunctionType(unwrappedfunc.func_code,
786
unwrappedfunc.func_globals,
787
unwrappedfunc.func_name,
788
unwrappedfunc.func_defaults,
789
unwrappedfunc.func_closure)
790
new_dbusfunc = dbus.service.signal(
791
new_interface, old_dbusobj._dbus_signature)(newfunc)
792
attr["_transitional_{0}_1".format(key)] = new_dbusfunc
793
attr["_transitional_{0}_0".format(key)] = old_dbusobj
794
def fixscope(func1, func2):
795
def newcall(*args, **kwargs):
796
func1(*args, **kwargs)
797
func2(*args, **kwargs)
800
attr[key] = fixscope(
801
old_dbusobj, attr["_transitional_{0}_1".format(key)])
803
if getattr(old_dbusobj, "_dbus_is_method", False):
804
new_dbusfunc = (dbus.service.method
806
old_dbusobj._dbus_in_signature,
807
old_dbusobj._dbus_out_signature)
809
(old_dbusobj.func_code,
810
old_dbusobj.func_globals,
811
old_dbusobj.func_name,
812
old_dbusobj.func_defaults,
813
old_dbusobj.func_closure)))
815
attr["_transitional_{0}".format(key)] = new_dbusfunc
816
if getattr(old_dbusobj, "_dbus_is_property", False):
817
new_dbusfunc = (dbus_service_property
819
old_dbusobj._dbus_signature,
820
old_dbusobj._dbus_access,
821
old_dbusobj._dbus_get_args_options["byte_arrays"])
823
(old_dbusobj.func_code,
824
old_dbusobj.func_globals,
825
old_dbusobj.func_name,
826
old_dbusobj.func_defaults,
827
old_dbusobj.func_closure)))
829
attr["_transitional_{0}".format(key)] = new_dbusfunc
830
return type.__new__(mcs, name, bases, attr)
760
832
class ClientDBus(Client, DBusObjectWithProperties):
761
833
"""A Client class using D-Bus
1185
1259
unicode(self.client_address))
1186
1260
logger.debug("Pipe FD: %d",
1187
1261
self.server.child_pipe.fileno())
1189
1263
session = (gnutls.connection
1190
1264
.ClientSession(self.request,
1191
1265
gnutls.connection
1192
1266
.X509Credentials()))
1194
1268
# Note: gnutls.connection.X509Credentials is really a
1195
1269
# generic GnuTLS certificate credentials object so long as
1196
1270
# no X.509 keys are added to it. Therefore, we can use it
1197
1271
# here despite using OpenPGP certificates.
1199
1273
#priority = ':'.join(("NONE", "+VERS-TLS1.1",
1200
1274
# "+AES-256-CBC", "+SHA1",
1201
1275
# "+COMP-NULL", "+CTYPE-OPENPGP",
1413
1488
This function creates a new pipe in self.pipe
1415
1490
parent_pipe, self.child_pipe = multiprocessing.Pipe()
1417
1492
super(MultiprocessingMixInWithPipe,
1418
1493
self).process_request(request, client_address)
1419
1494
self.child_pipe.close()
1420
1495
self.add_pipe(parent_pipe)
1422
1497
def add_pipe(self, parent_pipe):
1423
1498
"""Dummy function; override as necessary"""
1424
1499
raise NotImplementedError
1426
1502
class IPv6_TCPServer(MultiprocessingMixInWithPipe,
1427
1503
socketserver.TCPServer, object):
1428
1504
"""IPv6-capable TCP server. Accepts 'None' as address and/or port