Returns warning according to GetSystemPowerStatus().BatteryLifeTime/BatteryLifePercent

        @raise WindowsError if any underlying error occures.
717
def get_low_battery_warning_level(self):
        
        power_status = SYSTEM_POWER_STATUS()
        if not GetSystemPowerStatus(pointer(power_status)):
            raise WinError()

        if POWER_TYPE_MAP[power_status.ACLineStatus] == common.POWER_TYPE_AC:
            return common.LOW_BATTERY_WARNING_NONE
        else:
            if power_status.BatteryLifeTime != -1 and power_status.BatteryLifeTime <= 600:
                return common.LOW_BATTERY_WARNING_FINAL
            elif power_status.BatteryLifePercent <= 22:
                return common.LOW_BATTERY_WARNING_EARLY
            else:
                return common.LOW_BATTERY_WARNING_NONE
1261577
public function getBattery()
    {

        // Time?
        if (!empty($this->settings['timer'])) {
            $t = new Timer('Batteries');
        }

        // Store them here
        $batts = [];

        // Get result of program
        try {
            $res = $this->exec->exec('apm', '-abl');
        } catch (Exception $e) {
            Errors::add('Linfo Core', 'Error using `apm` battery info');

            return $batts;
        }

        // Values from program
        list(, $bat_status, $percentage) = explode("\n", $res);

        // Interpret status code
        switch ($bat_status) {
            case 0:
                $status = 'High';
            break;
            case 1:
                $status = 'Low';
            break;
            case 2:
                $status = 'Critical';
            break;
            case 3:
                $status = 'Charging';
            break;
            default:
                $status = 'Unknown';
            break;
        }

        // Save battery
        $batts[] = array(
            'percentage' => $percentage.'%',
            'state' => $status,
            'device' => 'battery',
        );

        // Return
        return $batts;
    }
878551
private int getLRDefinedWindow()
    {
        int leastRU         = Integer.MAX_VALUE;
        int whichWindow     = INVALIDWINDOW;

        // find least recently used window
        // supposedly faster to count down
        //for( int i = 0; i < NUMWINDOWS; i++ ) {
        for(int i = NUMWINDOWS - 1; i >= 0; --i ) {
            if( fTimeStamps[i] < leastRU ) {
                leastRU   = fTimeStamps[i];
                whichWindow  = i;
            }
        }

        return whichWindow;
    }
1270371
public String getHealthMemory() {
        StringBuilder sb = new StringBuilder();
        sb.append("Logging JVM Stats\n");
        MonitorProvider mp = MonitorProvider.getInstance();
        PerformUsage perf = mp.getJVMMemoryUsage();
        sb.append(perf.toString());

        if (perf.memoryUsagePercent >= THRESHOLD_PERCENT) {
            sb.append("========= WARNING: MEM USAGE > " + THRESHOLD_PERCENT
                    + "!!");
            sb.append(" !! Live Threads List=============\n");
            sb.append(mp.getThreadUsage().toString());
            sb.append("========================================\n");
            sb.append("========================JVM Thread Dump====================\n");
            ThreadInfo[] threadDump = mp.getThreadDump();
            for (ThreadInfo threadInfo : threadDump) {
                sb.append(threadInfo.toString() + "\n");
            }
            sb.append("===========================================================\n");
        }
        sb.append("Logged JVM Stats\n");

        return sb.toString();
    }
938650
def hardware_status(self):
        
        stat = structs.JLinkHardwareStatus()
        res = self._dll.JLINKARM_GetHWStatus(ctypes.byref(stat))
        if res == 1:
            raise errors.JLinkException('Error in reading hardware status.')
        return stat
1007213
@SuppressWarnings({"unused", "WeakerAccess"})
    public int getTimeElapsed() {
        int currentSession = getCurrentSession();
        if (currentSession == 0) return -1;

        int now = (int) (System.currentTimeMillis() / 1000);
        return now - currentSession;
    }
504858
async def get_power_settings(self) -> List[Setting]:
        """"""
        return [
            Setting.make(**x)
            for x in await self.services["system"]["getPowerSettings"]({})
        ]
931118
def get_sleep_timer(self):
        
        resp = self.avTransport.GetRemainingSleepTimerDuration([
            ('InstanceID', 0),
        ])
        if resp['RemainingSleepTimerDuration']:
            times = resp['RemainingSleepTimerDuration'].split(':')
            return (int(times[0]) * 3600 +
                    int(times[1]) * 60 +
                    int(times[2]))
        else:
            return None
110379
@Override
	public boolean isElementPresent(long timeout) throws WidgetException {
		final long start = System.currentTimeMillis();
		final long end = start + timeout;
		while (true) {
			if (isElementPresent()) {
				return true;
			}

			// Putting the condition here will measure the time more accurately.
			if (System.currentTimeMillis() >= end) {
				return false;
			}
			try {
				Thread.sleep(250);
			} catch (InterruptedException e) {
			}
		}
	}
1271450
def status_light(self):
        
        result = self.deviceProperties.GetLEDState()
        LEDState = result["CurrentLEDState"]  # pylint: disable=invalid-name
        return True if LEDState == "On" else False
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
609624
def get_time_remaining_estimate(self):
        
        all_energy_now = []
        all_energy_not_discharging = []
        all_power_now = []
        for supply in os.listdir(POWER_SUPPLY_PATH):
            supply_path = os.path.join(POWER_SUPPLY_PATH, supply)
            try:
                type = self.power_source_type(supply_path)
                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(supply_path) and self.is_battery_discharging(supply_path):
                        energy_full, energy_now, power_now = self.get_battery_state(supply_path)
                        all_energy_now.append(energy_now)
                        all_power_now.append(power_now)
                    elif self.is_battery_present(supply_path) and not self.is_battery_discharging(supply_path):
                        energy_now = self.get_battery_state(supply_path)[1]
                        all_energy_not_discharging.append(energy_now)
                else:
                    warnings.warn("UPS is not supported.")
            except (RuntimeError, IOError) as e:
                warnings.warn("Unable to read properties of {0}: {1}".format(supply_path, e), 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)])\
                    + sum(all_energy_not_discharging) / (sum(all_power_now) / len(all_power_now)) * 60.0
            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
610857
public boolean isLowOnResources()
    {
        int spare=getMaxThreads()-getThreads();
        int lr = _lowResources>0?_lowResources:getMinThreads();
        boolean low = (spare+getIdleThreads())<lr;
        
        if (low && !_isLow)
        {
            log.info("LOW ON THREADS (("+
                      getMaxThreads()+"-"+
                      getThreads()+"+"+
                      getIdleThreads()+")<"+
                      getMinThreads()+") on "+ this);
            _warned=System.currentTimeMillis();
            _isLow=true;
        }
        else if (!low && _isLow)
        {
            if (System.currentTimeMillis()-_warned > 1000)
            {
                _isOut=false;
                _isLow=false;
            }
        }
        return low;
    }
216342
def get(cls):
        
        stats = {}
        cur_time = time.time()
        # minimum interval for getting CPU and memory statistics
        if cur_time < cls._last_measurement or \
           cur_time > cls._last_measurement + 1.9:
            cls._last_measurement = cur_time
            # Non blocking call to get cpu usage. First call will return 0
            cls._last_cpu_percent = psutil.cpu_percent(interval=None)
            cls._last_mem_percent = psutil.virtual_memory().percent
        stats["cpu_usage_percent"] = cls._last_cpu_percent
        stats["memory_usage_percent"] = cls._last_mem_percent
        return stats
1026397
public SystemInputDef getSystemInputDef()
    {
    return
      getType() == JSON?
      new SystemInputJsonReader( open()).getSystemInputDef() :

      new SystemInputDocReader( open()).getSystemInputDef();
    }
1290619
def get_providing_power_source_type(self):
        
        power_status = SYSTEM_POWER_STATUS()
        if not GetSystemPowerStatus(pointer(power_status)):
            raise WinError()
        return POWER_TYPE_MAP[power_status.ACLineStatus]
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