Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: client/cros/power_status.py

Issue 6627029: Refactor site_power_status, power_strip modules into client/cros. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: patch Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | client/cros/power_strip.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import glob, logging, os, re, time 1 import glob, logging, os, re, time
2 from autotest_lib.client.bin import utils as bin_utils 2 from autotest_lib.client.bin import utils
3 from autotest_lib.client.common_lib import error, utils 3 from autotest_lib.client.common_lib import error
4 4
5 5
6 class DevStat(object): 6 class DevStat(object):
7 """ 7 """
8 Device power status. This class implements generic status initialization 8 Device power status. This class implements generic status initialization
9 and parsing routines. 9 and parsing routines.
10 """ 10 """
11 11
12 def __init__(self, fields, path=None): 12 def __init__(self, fields, path=None):
13 self.fields = fields 13 self.fields = fields
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 class CPUIdleStats(object): 256 class CPUIdleStats(object):
257 """ 257 """
258 CPU Idle statistics 258 CPU Idle statistics
259 """ 259 """
260 # TODO (snanda): Handle changes in number of c-states due to events such 260 # TODO (snanda): Handle changes in number of c-states due to events such
261 # as ac <-> battery transitions. 261 # as ac <-> battery transitions.
262 # TODO (snanda): Handle non-S0 states. Time spent in suspend states is 262 # TODO (snanda): Handle non-S0 states. Time spent in suspend states is
263 # currently not factored out. 263 # currently not factored out.
264 264
265 def __init__(self): 265 def __init__(self):
266 self._num_cpus = bin_utils.count_cpus() 266 self._num_cpus = utils.count_cpus()
267 self._time = time.time() 267 self._time = time.time()
268 self._stats = self._read_stats() 268 self._stats = self._read_stats()
269 269
270 270
271 def refresh(self): 271 def refresh(self):
272 """ 272 """
273 This method returns the percentage time spent in each of the CPU 273 This method returns the percentage time spent in each of the CPU
274 idle states. The stats returned are from whichever is the later of: 274 idle states. The stats returned are from whichever is the later of:
275 a) time this class was instantiated, or 275 a) time this class was instantiated, or
276 b) time when refresh was last called 276 b) time when refresh was last called
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 389
390 active = int(utils.read_file(active_duration_path)) 390 active = int(utils.read_file(active_duration_path))
391 connected = int(utils.read_file(connected_duration_path)) 391 connected = int(utils.read_file(connected_duration_path))
392 logging.debug('device %s active for %.2f%%', 392 logging.debug('device %s active for %.2f%%',
393 path, active * 100.0 / connected) 393 path, active * 100.0 / connected)
394 394
395 total_active += active 395 total_active += active
396 total_connected += connected 396 total_connected += connected
397 397
398 return total_active, total_connected 398 return total_active, total_connected
OLDNEW
« no previous file with comments | « no previous file | client/cros/power_strip.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698