Skip to content

Commit

Permalink
ctl: Factor out running update step with a given proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
wjt committed Nov 15, 2024
1 parent 783beb3 commit b6ae73b
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions eos-updater-ctl/eos-updater-ctl
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ def name_vanished_cb(connection, name):
print("%s disappeared" % name)


def command_dbus(command, block, quiet=False, parameters=None):
"""Run the given command and wait for it to complete."""
bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
def command_with_proxy(proxy, command, block, quiet=False, parameters=None):
(function_name, in_progress_state) = METHODS[command]

def signal_cb(proxy, sender_name, signal_name, parameters, user_data):
Expand All @@ -165,10 +163,6 @@ def command_dbus(command, block, quiet=False, parameters=None):
elif new_state != in_progress_state and seen_in_progress_state:
seen_next_state = True

proxy = Gio.DBusProxy.new_sync(bus, 0, None,
'com.endlessm.Updater',
'/com/endlessm/Updater',
'com.endlessm.Updater', None)
signal_id = proxy.connect('g-signal', signal_cb, None)
context = GLib.main_context_default()

Expand Down Expand Up @@ -202,6 +196,17 @@ def command_dbus(command, block, quiet=False, parameters=None):
return 0


def command_dbus(command, block, quiet=False, parameters=None):
"""Run the given command and wait for it to complete."""
bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
proxy = Gio.DBusProxy.new_sync(bus, 0, None,
'com.endlessm.Updater',
'/com/endlessm/Updater',
'com.endlessm.Updater', None)

return command_with_proxy(proxy, command, block, quiet=quiet, parameters=parameters)


def command_poll(block, quiet=False):
return command_dbus('poll', block, quiet)

Expand Down

0 comments on commit b6ae73b

Please sign in to comment.