示例#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
示例#2
0
文件: check.py 项目: xeon-zolt/Cnchi
    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
示例#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
示例#4
0
文件: check.py 项目: EntityOS/Cnchi
    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
示例#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