def _background(meta, oauth, dialog, builder):
    try:
        cert, key = create_keypair(oauth, meta.api_base_uri)
        meta.cert = cert
        meta.key = key
        meta.config = get_profile_config(oauth, meta.api_base_uri,
                                         meta.profile_id)
    except Exception as e:
        GLib.idle_add(
            lambda: error_helper(dialog, "can't finalize configuration",
                                 "{}: {}".format(type(e).__name__, str(e))))
        GLib.idle_add(lambda: dialog.hide())
        raise
    else:
        try:
            uuid = store_provider(meta)
            monitor_vpn(
                uuid=uuid,
                callback=lambda *args, **kwargs: vpn_change(builder=builder))
            GLib.idle_add(
                lambda: notify("eduVPN provider added", "added provider '{}'".
                               format(meta.display_name)))
        except Exception as e:
            GLib.idle_add(
                lambda: error_helper(dialog, "can't store configuration",
                                     "{} {}".format(type(e).__name__, str(e))))
            GLib.idle_add(lambda: dialog.hide())
            raise
        else:
            GLib.idle_add(lambda: dialog.hide())
            GLib.idle_add(lambda: update_providers(builder))
Esempio n. 2
0
def _background(meta, dialog, builder, config_dict, lets_connect):
    try:
        uuid = store_provider(meta, config_dict)
        monitor_vpn(uuid=uuid, callback=lambda *args, **kwargs: vpn_change(builder=builder, lets_connect=lets_connect))
        notification = init_notify(lets_connect)
        GLib.idle_add(lambda: notify(notification, "eduVPN provider added",
                                     "added provider '{}'".format(meta.display_name)))
    except Exception as e:
        error = e
        GLib.idle_add(lambda: error_helper(dialog, "can't store configuration", "{}: {}".format(type(error).__name__,
                                                                                                str(error))))
        GLib.idle_add(lambda: dialog.hide())
        raise
    else:
        GLib.idle_add(lambda: dialog.hide())
        GLib.idle_add(lambda: refresh_start(builder, lets_connect=lets_connect))
Esempio n. 3
0
 def vpn_change(self, state, reason):
     """called when the status of a VPN connection changes"""
     logger.debug("VPN status change, state: {}, reason: {}".format(
         state, reason))
     vpn_change(self.builder, self.lets_connect, state, reason)
 def test_vpn_change(self):
     vpn_change(builder=self.builder, lets_connect=False)
Esempio n. 5
0
 def test_vpn_change(self):
     vpn_change(builder=self.builder)
Esempio n. 6
0
 def vpn_change(self, *args, **kwargs):
     """called when the status of a VPN connection changes"""
     vpn_change(self.builder)