pytools: obmcutil: Implement blocking behaviour

The technique to block is to attach a listener for systemd JobRemoved
property change events, change the desired OpenBMC state
management property to trigger the systemd transition, and then run the
gobject dbus mainloop. We terminate the mainloop by invoking quit() in
the callback on the captured mainloop object.

Additionally, the result of the transition (success or failure) is
judged in the callback. We can't obtain the result by returning it, and
as we are using Python 2 we cannot meaningfully mutate captured
variables to expose it. Instead, a variable is created on the callback
function object after it is defined but before the function is invoked,
which is mutated inside the function (which can reference its own
object) when called. The result is retrieved after the mainloop has
terminated and is propagated up the call chain to form the exit status.

Change-Id: Ic19aa604631177abea7580de2357d8c6812ee874
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
1 file changed