Looks through all power sources and returns total time remaining estimate
        or TIME_REMAINING_UNLIMITED if ac power supply is online.
431974
def get_time_remaining_estimate(self):
        
        all_energy_now = []
        all_power_now = []
        try:
            type = self.power_source_type()
            if type == common.POWER_TYPE_AC:
                if self.is_ac_online(supply_path):
                    return common.TIME_REMAINING_UNLIMITED
            elif type == common.POWER_TYPE_BATTERY:
                if self.is_battery_present() and self.is_battery_discharging():
                    energy_full, energy_now, power_now = self.get_battery_state()
                    all_energy_now.append(energy_now)
                    all_power_now.append(power_now)
            else:
                warnings.warn("UPS is not supported.")
        except (RuntimeError, IOError) as e:
            warnings.warn("Unable to read system power information!", category=RuntimeWarning)

        if len(all_energy_now) > 0:
            try:
                return sum([energy_now / power_now * 60.0 for energy_now, power_now in zip(all_energy_now, all_power_now)])
            except ZeroDivisionError as e:
                warnings.warn("Unable to calculate time remaining estimate: {0}".format(e), category=RuntimeWarning)
                return common.TIME_REMAINING_UNKNOWN
        else:
            return common.TIME_REMAINING_UNKNOWN
185336
def get_all_active(self):
        
        now = timezone.now()
        return self.select_related().filter(active_datetime__lte=now,
                                              inactive_datetime__gte=now).order_by('active_datetime')
459434
def is_running(self):
        
        return self._state in [self.STATE_ACTIVE,
                               self.STATE_IDLE,
                               self.STATE_INITIALIZING]
1271452
def elapsed(self):
        

        # Clock stops running when total is reached
        if self.count == self.total:
            elapsed = self.last_update - self.start
        else:
            elapsed = time.time() - self.start

        return elapsed
690113
def getChargingCurrent(self):
    """"""
    command = '$GG'
    currentAndVoltage = self.sendCommand(command)
    amps = float(currentAndVoltage[1])/1000
    return amps
839522
def get_consumption(self):
        """"""
        self.get_status()
        try:
            self.consumption = self.data['power']
        except TypeError:
            self.consumption = 0

        return self.consumption
1104739
def getChargingVoltage(self):
    """"""
    command = '$GG'
    currentAndVoltage = self.sendCommand(command)
    volts = float(currentAndVoltage[2])/1000
    return volts
378818
def battery_reported(self, voltage, rawVoltage):
        """"""
        self._update_attribute(BATTERY_PERCENTAGE_REMAINING, voltage)
        self._update_attribute(self.BATTERY_VOLTAGE_ATTR,
                               int(rawVoltage / 100))
622897
def get_over_current(self, channel):
        '''
        '''
        try:
            bit = self._ch_map[channel]['GPIOOC']['bit']
        except KeyError:
            raise ValueError('get_over_current() not supported for channel %s' % channel)
        return not self._get_power_gpio_value(bit)
867788
def getNewestCompleteTime(self):
        
        bldrid = yield self.getBuilderId()
        completed = yield self.master.data.get(
            ('builders', bldrid, 'buildrequests'),
            [resultspec.Filter('complete', 'eq', [False])],
            order=['-complete_at'], limit=1)
        if completed:
            return completed[0]['complete_at']
        else:
            return None
1116421
def available(self):
        """"""
        if not self.adb_server_ip:
            # python-adb
            return bool(self._adb)

        # pure-python-adb
        try:
            # make sure the server is available
            adb_devices = self._adb_client.devices()

            # make sure the device is available
            try:
                # case 1: the device is currently available
                if any([self.host in dev.get_serial_no() for dev in adb_devices]):
                    if not self._available:
                        self._available = True
                    return True

                # case 2: the device is not currently available
                if self._available:
                    logging.error('ADB server is not connected to the device.')
                    self._available = False
                return False

            except RuntimeError:
                if self._available:
                    logging.error('ADB device is unavailable; encountered an error when searching for device.')
                    self._available = False
                return False

        except RuntimeError:
            if self._available:
                logging.error('ADB server is unavailable.')
                self._available = False
            return False
746235
def hascurrent(self, allowempty=False):
        """"""
        for e in self.select(Current,None,False, False):
            if not allowempty and len(e) == 0: continue
            return True
        return False
649769
def power_on
      target = entity_xml
      class_name = self.class.name.split("::").last
      Config.logger.debug "#{class_name} status: #{target[:status]}"
      if is_status?(target, :POWERED_ON)
        Config.logger.info "#{class_name} #{target.name} is already powered-on."
        return
      end

      power_on_link = target.power_on_link
      unless power_on_link
        fail CloudError,
             "#{class_name} #{target.name} not in a state able to power on."
      end

      Config.logger.info "Powering on #{class_name} #{target.name}."
      task = connection.post(power_on_link.href, nil)
      task = monitor_task task, @session.time_limit[:power_on]
      Config.logger.info "#{class_name} #{target.name} is powered on."
      self
    end
390018
public int getTotalCpuPercent() {
		if (invalidMonitor.get()) {
			return 0;
		}
		long now = System.currentTimeMillis();
		int cpu;
		synchronized (Monitor.class) {
			if (now - cpuDetectedAt > cacheTimeout) {
				try {
					cachedCPU = detectTotalCpuPercent();
				} catch (Throwable cause) {
					logger.info("Unable to detect CPU usage!", cause);
					invalidMonitor.set(true);
				}
				cpuDetectedAt = now;
			}
			cpu = cachedCPU;
		}
		return cpu;
	}
290877
def fetch_data_detailled_energy_use(self, start_date=None, end_date=None):
        """"""
        if start_date is None:
            start_date = datetime.datetime.now(HQ_TIMEZONE) - datetime.timedelta(days=1)
        if end_date is None:
            end_date = datetime.datetime.now(HQ_TIMEZONE)
        # Get http session
        yield from self._get_httpsession()
        # Get login page
        login_url = yield from self._get_login_page()
        # Post login page
        yield from self._post_login_page(login_url)
        # Get p_p_id and contracts
        p_p_id, contracts = yield from self._get_p_p_id_and_contract()
        # If we don't have any contrats that means we have only
        # onecontract. Let's get it
        if contracts == {}:
            contracts = yield from self._get_lonely_contract()
        # For all contracts
        for contract, contract_url in contracts.items():
            if contract_url:
                yield from self._load_contract_page(contract_url)

            data = {}
            dates = [(start_date + datetime.timedelta(n))
                     for n in range(int((end_date - start_date).days))]

            for date in dates:
                # Get Hourly data
                day_date = date.strftime("%Y-%m-%d")
                hourly_data = yield from self._get_hourly_data(day_date, p_p_id)
                data[day_date] = hourly_data['raw_hourly_data']

            # Add contract
            self._data[contract] = data
505477
def get_host_power_status(self):
        
        sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID)
        return GET_POWER_STATE_MAP.get(sushy_system.power_state)
762197
def on_power_source_notification(self):
        
        for weak_observer in self._weak_observers:
            observer = weak_observer()
            if observer:
                observer.on_power_sources_change(self)
                observer.on_time_remaining_change(self)