Exemple #1
0
    def on_battery_power(self):
        """ Checks if we are on battery power """
        if not self.has_battery():
            return False

        bus = dbus.SystemBus()
        upower = bus.get_object(UPOWER, UPOWER_PATH)
        if misc.get_prop(upower, UPOWER_PATH, 'OnBattery'):
            return True
Exemple #2
0
    def on_battery_power(self):
        """ Checks if we are on battery power """
        if not self.has_battery():
            return False

        bus = dbus.SystemBus()
        upower = bus.get_object(UPOWER, UPOWER_PATH)
        if misc.get_prop(upower, UPOWER_PATH, 'OnBattery'):
            return True
Exemple #3
0
    def on_battery(self):
        """ Checks if we are on battery power """
        import dbus

        if self.has_battery():
            bus = dbus.SystemBus()
            upower = bus.get_object(UPOWER, UPOWER_PATH)
            return misc.get_prop(upower, UPOWER_PATH, 'OnBattery')

        return False
Exemple #4
0
    def on_battery(self):
        """ Checks if we are on battery power """
        import dbus

        if self.has_battery():
            bus = dbus.SystemBus()
            upower = bus.get_object(UPOWER, UPOWER_PATH)
            result = misc.get_prop(upower, UPOWER_PATH, 'OnBattery')
            if result == None:
                # Cannot read property, something is wrong.
                logging.error("Cannot read %s dbus property", UPOWER_PATH)
                # We will assume we are connected to a power supply
                result = False
            return result

        return False
Exemple #5
0
    def on_battery(self):
        """ Checks if we are on battery power """
        import dbus

        if self.has_battery():
            bus = dbus.SystemBus()
            upower = bus.get_object(UPOWER, UPOWER_PATH)
            result = misc.get_prop(upower, UPOWER_PATH, 'OnBattery')
            if result == None:
                # Cannot read property, something is wrong.
                logging.error("Cannot read %s dbus property", UPOWER_PATH)
                # We will assume we are connected to a power supply
                result = False
            return result

        return False