| OLD | NEW |
| 1 import glob, logging, os, re, time | 1 import glob, logging, os, re, time |
| 2 from autotest_lib.client.bin import utils | 2 from autotest_lib.client.bin import utils |
| 3 from autotest_lib.client.common_lib import error | 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 """ |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 def refresh(self): | 235 def refresh(self): |
| 236 """ | 236 """ |
| 237 Initialize device power status objects for a single battery and a | 237 Initialize device power status objects for a single battery and a |
| 238 single power line by parsing the output of devkit-power -d. | 238 single power line by parsing the output of devkit-power -d. |
| 239 """ | 239 """ |
| 240 self.battery = [ BatteryStat(self.battery_path) ] | 240 self.battery = [ BatteryStat(self.battery_path) ] |
| 241 self.linepower = [ LineStat(self.linepower_path) ] | 241 self.linepower = [ LineStat(self.linepower_path) ] |
| 242 self.thermal = [ ThermalStat(self.thermal_path) ] | 242 self.thermal = [ ThermalStat(self.thermal_path) ] |
| 243 | 243 |
| 244 try: | 244 try: |
| 245 if self.thermal[0].temp < self.min_temp * 1000: | 245 if self.thermal[0].temp < self.min_temp: |
| 246 self.min_temp = float(self.thermal[0].temp) / 1000 | 246 self.min_temp = self.thermal[0].temp |
| 247 if self.thermal[0].temp > self.max_temp * 1000: | 247 if self.thermal[0].temp > self.max_temp: |
| 248 self.max_temp = float(self.thermal[0].temp) / 1000 | 248 self.max_temp = self.thermal[0].temp |
| 249 logging.info('Temperature reading: ' + self.thermal[0].temp) | 249 logging.info('Temperature reading: ' + str(self.thermal[0].temp)) |
| 250 except: | 250 except: |
| 251 logging.error('Could not read temperature, skipping.') | 251 logging.error('Could not read temperature, skipping.') |
| 252 | 252 |
| 253 | 253 |
| 254 def get_status(): | 254 def get_status(): |
| 255 """ | 255 """ |
| 256 Return a new power status object (SysStat). A new power status snapshot | 256 Return a new power status object (SysStat). A new power status snapshot |
| 257 for a given host can be obtained by either calling this routine again and | 257 for a given host can be obtained by either calling this routine again and |
| 258 constructing a new SysStat object, or by using the refresh method of the | 258 constructing a new SysStat object, or by using the refresh method of the |
| 259 SysStat object. | 259 SysStat object. |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 | 470 |
| 471 active = int(utils.read_file(active_duration_path)) | 471 active = int(utils.read_file(active_duration_path)) |
| 472 connected = int(utils.read_file(connected_duration_path)) | 472 connected = int(utils.read_file(connected_duration_path)) |
| 473 logging.debug('device %s active for %.2f%%', | 473 logging.debug('device %s active for %.2f%%', |
| 474 path, active * 100.0 / connected) | 474 path, active * 100.0 / connected) |
| 475 | 475 |
| 476 total_active += active | 476 total_active += active |
| 477 total_connected += connected | 477 total_connected += connected |
| 478 | 478 |
| 479 return total_active, total_connected | 479 return total_active, total_connected |
| OLD | NEW |