Make connections volatile instead of removing them

This keeps the profile up in Network Manager for
persistent_state:absent.
This commit is contained in:
Till Maas 2018-08-21 13:06:48 +02:00
parent 9314a2b251
commit 6fc00a0d43
2 changed files with 95 additions and 26 deletions

View file

@ -126,6 +126,29 @@ class Util:
def create_cancellable(cls):
return cls.Gio().Cancellable.new()
@classmethod
def create_callback(cls, finish_method):
"""
Create a callback that will return the result of the finish method and
quit the GMainLoop
:param finish_method str: Name of the finish method to call from the
source object in the callback
"""
def callback(source_object, res, user_data):
success = None
try:
success = getattr(source_object, finish_method)(res)
except Exception as e:
if cls.error_is_cancelled(e):
return
user_data["error"] = str(e)
user_data["success"] = success
cls.GMainLoop().quit()
return callback
@classmethod
def error_is_cancelled(cls, e):
GLib = cls.GLib()