def main():
    logging.basicConfig(level=logging.DEBUG)

    if not upower_present(connect_dbus_system):
        raise EnvironmentError("DBUS connection to UPower impossible")

    conn = connect_dbus_system()

    conn.add_handler(UPowerDeviceHandler(connect_dbus_system,
                                         set(ibatteries(conn))))
    conn.subscribe_to_signals()

    # basic select() loop, i.e. we assume there is no event loop
    conn.dispatch()