xref: /aosp_15_r20/external/autotest/autotest_lib/client/bin/temperature.py (revision 9c5db1993ded3edbeafc8092d69fe5de2ee02df7)
1#!/usr/bin/env python
2# Lint as: python2, python3
3
4from __future__ import absolute_import
5from __future__ import division
6from __future__ import print_function
7
8import argparse
9
10argparser = argparse.ArgumentParser(
11    description="Get the highest reported board temperature (all sensors) in "
12                "Celsius.")
13
14group = argparser.add_mutually_exclusive_group()
15group.add_argument("-m", "--maximum",
16                   action="store_const",
17                   const='Maximum',
18                   dest="temperature_type",
19                   help="Get the highest reported board temperature "
20                        "from all sensors in Celsius.")
21args = argparser.add_argument("-v", "--verbose",
22                              action="store_true",
23                              help="Show temperature type and value.")
24argparser.set_defaults(temperature_type='all')
25args = argparser.parse_args()
26
27import common
28from autotest_lib.client.bin import utils
29
30TEMPERATURE_TYPE = {
31    'Maximum': utils.get_current_temperature_max,
32}
33
34def print_temperature(temperature_type):
35    if args.verbose:
36        print(temperature_type, end=' ')
37    print(TEMPERATURE_TYPE.get(temperature_type)())
38
39if args.temperature_type == 'all':
40    for temperature_type in list(TEMPERATURE_TYPE.keys()):
41        print_temperature(temperature_type)
42else:
43    print_temperature(args.temperature_type)
44