mirror of
https://github.com/linux-system-roles/network.git
synced 2026-07-20 17:59:00 +00:00
Make connections volatile instead of removing them
This keeps the profile up in Network Manager for persistent_state:absent.
This commit is contained in:
parent
9314a2b251
commit
6fc00a0d43
2 changed files with 95 additions and 26 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue