diff options
| author | Michael Biebl <biebl@debian.org> | 2014-07-06 02:16:10 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2014-07-06 02:16:10 +0200 |
| commit | 33491bc4279481db8ae47213e34a6d695a0e8830 (patch) | |
| tree | 097d2b0fdff3fae6885381ae5e57a182cd8cbbba /libnm-glib/tests/test-remote-settings-service.py | |
| parent | 59c3714a494c3b3765657c0551ad82842d98a7d2 (diff) | |
Imported Upstream version 0.9.10.0 upstream/0.9.10.0
Diffstat (limited to 'libnm-glib/tests/test-remote-settings-service.py')
| -rwxr-xr-x | libnm-glib/tests/test-remote-settings-service.py | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/libnm-glib/tests/test-remote-settings-service.py b/libnm-glib/tests/test-remote-settings-service.py index 86542005..439073ad 100755 --- a/libnm-glib/tests/test-remote-settings-service.py +++ b/libnm-glib/tests/test-remote-settings-service.py @@ -1,8 +1,9 @@ #!/usr/bin/env python # -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- -import glib -import gobject +from __future__ import print_function + +from gi.repository import GLib, GObject import sys import dbus import dbus.service @@ -21,7 +22,7 @@ class UnknownPropertyException(dbus.DBusException): class PermissionDeniedException(dbus.DBusException): _dbus_error_name = IFACE_SETTINGS + '.PermissionDenied' -mainloop = gobject.MainLoop() +mainloop = GObject.MainLoop() class Connection(dbus.service.Object): def __init__(self, bus, object_path, settings, remove_func): @@ -30,7 +31,25 @@ class Connection(dbus.service.Object): self.settings = settings self.remove_func = remove_func self.visible = True + self.props = {} + self.props['Unsaved'] = False + + # Properties interface + @dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE, in_signature='s', out_signature='a{sv}') + def GetAll(self, iface): + if iface != IFACE_CONNECTION: + raise UnknownInterfaceException() + return self.props + + @dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE, in_signature='ss', out_signature='v') + def Get(self, iface, name): + if iface != IFACE_CONNECTION: + raise UnknownInterfaceException() + if not name in self.props.keys(): + raise UnknownPropertyException() + return self.props[name] + # Connection methods @dbus.service.method(dbus_interface=IFACE_CONNECTION, in_signature='', out_signature='a{sa{sv}}') def GetSettings(self): if not self.visible: @@ -72,10 +91,10 @@ class Settings(dbus.service.Object): @dbus.service.method(dbus_interface=IFACE_SETTINGS, in_signature='a{sa{sv}}', out_signature='o') def AddConnection(self, settings): - path = "/org/freedesktop/NetworkManager/Settings/Connection/%d" % self.counter + path = "/org/freedesktop/NetworkManager/Settings/Connection/{0}".format(self.counter) self.counter = self.counter + 1 self.connections[path] = Connection(self.bus, path, settings, self.delete_connection) - print "Added connection %s" % path + print("Added connection {0}".format(path)) return path def delete_connection(self, connection): @@ -114,16 +133,16 @@ def main(): if not bus.request_name("org.freedesktop.NetworkManager"): sys.exit(1) - print "Service started" + print("Service started") - gobject.timeout_add_seconds(20, quit_cb, None) + GLib.timeout_add_seconds(20, quit_cb, None) try: mainloop.run() - except Exception, e: + except Exception as e: pass - print "Service stopped" + print("Service stopped") sys.exit(0) if __name__ == '__main__': |