From 108f5b3c24261a3f9c319e30519bbf06fd13ab1b Mon Sep 17 00:00:00 2001 From: Mike Gerber Date: Sat, 17 Dec 2016 19:04:57 +0100 Subject: [PATCH] Call D-Bus methods a little more symmetricly --- check_systemd_state | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/check_systemd_state b/check_systemd_state index 172e70e..5223997 100755 --- a/check_systemd_state +++ b/check_systemd_state @@ -20,14 +20,15 @@ proxy = bus.get_object('org.freedesktop.systemd1', '/org/freedesktop/systemd1') def get_system_state(): """Get system state.""" - properties_manager = dbus.Interface(proxy, 'org.freedesktop.DBus.Properties') - system_state = properties_manager.Get('org.freedesktop.systemd1.Manager', 'SystemState') + properties = dbus.Interface(proxy, 'org.freedesktop.DBus.Properties') + system_state = properties.Get('org.freedesktop.systemd1.Manager', 'SystemState') return system_state def get_failed_units(): """Get a list of failed system units.""" - units = proxy.ListUnits(dbus_interface='org.freedesktop.systemd1.Manager') + manager = dbus.Interface(proxy, 'org.freedesktop.systemd1.Manager') + units = manager.ListUnits() failed_units = [] for u in units: service, _, loaded, active, state = u[:5]