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

Side by Side Diff: tools/telemetry/telemetry/core/platform/power_monitor/android_temperature_monitor.py

Issue 806843002: Reland of Migrate DeviceUtils.ReadFile to adb_wrapper (try 3) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: enable command line test only for android Created 5 years, 10 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
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import telemetry.core.platform.power_monitor as power_monitor 5 from telemetry.core import util
6 from telemetry.core.platform import power_monitor
7
8 util.AddDirToPythonPath(util.GetChromiumSrcDir(), 'build', 'android')
9 try:
10 from pylib.device import device_errors # pylint: disable=F0401
11 except ImportError:
12 device_errors = None
13
6 14
7 _TEMPERATURE_FILE = '/sys/class/thermal/thermal_zone0/temp' 15 _TEMPERATURE_FILE = '/sys/class/thermal/thermal_zone0/temp'
8 16
9 17
10 class AndroidTemperatureMonitor(power_monitor.PowerMonitor): 18 class AndroidTemperatureMonitor(power_monitor.PowerMonitor):
11 """ 19 """
12 Delegates monitoring to another PowerMonitor and adds temperature measurements 20 Delegates monitoring to another PowerMonitor and adds temperature measurements
13 to overall results. 21 to overall results.
14 """ 22 """
15 def __init__(self, monitor, device): 23 def __init__(self, monitor, device):
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 for path_element in temperature_path[:-1]: 58 for path_element in temperature_path[:-1]:
51 if not path_element in temperature_insertion_point: 59 if not path_element in temperature_insertion_point:
52 temperature_insertion_point[path_element] = {} 60 temperature_insertion_point[path_element] = {}
53 temperature_insertion_point = temperature_insertion_point[path_element] 61 temperature_insertion_point = temperature_insertion_point[path_element]
54 assert temperature_path[-1] not in temperature_insertion_point 62 assert temperature_path[-1] not in temperature_insertion_point
55 temperature_insertion_point[temperature_path[-1]] = average_temperature 63 temperature_insertion_point[temperature_path[-1]] = average_temperature
56 64
57 return power_data 65 return power_data
58 66
59 def _GetBoardTemperatureCelsius(self): 67 def _GetBoardTemperatureCelsius(self):
60 contents = self._device.ReadFile(_TEMPERATURE_FILE) 68 try:
61 if len(contents) > 0: 69 contents = self._device.ReadFile(_TEMPERATURE_FILE)
62 return float(contents[0]) 70 return float(contents) if contents else None
63 return None 71 except device_errors.CommandFailedError:
72 return None
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698