Пример #1
0
def switched(meta, builder, verifier, lets_connect):
    # type: (Metadata, Gtk.builder, str, bool) -> None
    switch = builder.get_object('connect-switch')
    state = switch.get_active()
    logger.info(u"switch activated, old state {}".format(state))
    if not state:
        logger.info(u"setting switch ON")
        GLib.idle_add(lambda: switch.set_active(True))
        activate_connection(meta=meta,
                            builder=builder,
                            verifier=verifier,
                            lets_connect=lets_connect)
    else:
        notification = init_notify(lets_connect)
        notify(notification, u"eduVPN disconnecting...",
               u"Disconnecting from {}".format(meta.display_name))
        logger.info(u"setting switch OFF")
        GLib.idle_add(lambda: switch.set_active(False))
        try:
            disconnect_provider(meta.uuid)
        except Exception as e:
            window = builder.get_object('eduvpn-window')
            error_helper(window, u"can't disconnect",
                         "{}: {}".format(type(e).__name__, str(e)))
            GLib.idle_add(lambda: switch.set_active(True))
            raise
Пример #2
0
def switched(meta, builder):
    switch = builder.get_object('connect-switch')
    state = switch.get_active()
    logger.info("switch activated, old state {}".format(state))
    if not state:
        logger.info("setting switch ON")
        GLib.idle_add(lambda: switch.set_active(True))
        activate_connection(meta=meta, builder=builder)
    else:
        notify("eduVPN disconnecting...", "Disconnecting from {}".format(meta.display_name))
        logger.info("setting switch OFF")
        GLib.idle_add(lambda: switch.set_active(False))
        try:
            disconnect_provider(meta.uuid)
        except Exception as e:
            window = builder.get_object('eduvpn-window')
            error_helper(window, "can't disconnect", "{}: {}".format(type(e).__name__, str(e)))
            GLib.idle_add(lambda: switch.set_active(True))
            raise
Пример #3
0
 def test_activate_connection(self, *args):
     activate_connection(builder=self.builder, meta=self.meta, verifier=self.verifier, lets_connect=False)
Пример #4
0
 def test_activate_connection(self, *args):
     activate_connection(builder=self.builder, meta=self.meta)