Chromium Code Reviews| Index: tools/telemetry/telemetry/core/platform/power_monitor/android_temperature_monitor.py |
| diff --git a/tools/telemetry/telemetry/core/platform/power_monitor/android_temperature_monitor.py b/tools/telemetry/telemetry/core/platform/power_monitor/android_temperature_monitor.py |
| index fa56bab3c33b7a7c6dc900b50d8a91f8795fe426..2b61e6287781a0245ea10eb285ffe3e3a43d05e3 100644 |
| --- a/tools/telemetry/telemetry/core/platform/power_monitor/android_temperature_monitor.py |
| +++ b/tools/telemetry/telemetry/core/platform/power_monitor/android_temperature_monitor.py |
| @@ -2,7 +2,15 @@ |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| -import telemetry.core.platform.power_monitor as power_monitor |
| +from telemetry.core import util |
| +from telemetry.core.platform import power_monitor |
| + |
| +util.AddDirToPythonPath(util.GetChromiumSrcDir(), 'build', 'android') |
| +try: |
| + from pylib.device import device_errors # pylint: disable=F0401 |
| +except ImportError: |
| + device_errors = None |
| + |
| _TEMPERATURE_FILE = '/sys/class/thermal/thermal_zone0/temp' |
| @@ -57,7 +65,8 @@ class AndroidTemperatureMonitor(power_monitor.PowerMonitor): |
| return power_data |
| def _GetBoardTemperatureCelsius(self): |
|
jbudorick
2014/12/09 17:48:59
(i.e., no logging in the original)
|
| - contents = self._device.ReadFile(_TEMPERATURE_FILE) |
| - if len(contents) > 0: |
| - return float(contents[0]) |
| - return None |
| + try: |
| + contents = self._device.ReadFile(_TEMPERATURE_FILE) |
| + return float(contents) if contents else None |
| + except device_errors.CommandFailedError: |
| + return None |