aboutsummaryrefslogtreecommitdiff
path: root/client/bin/temperature.py
blob: c1d23ee3705d2289a3aeb81f5501313fca76b889 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
# Lint as: python2, python3

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import argparse

argparser = argparse.ArgumentParser(
    description="Get the highest reported board temperature (all sensors) in "
                "Celsius.")

group = argparser.add_mutually_exclusive_group()
group.add_argument("-m", "--maximum",
                   action="store_const",
                   const='Maximum',
                   dest="temperature_type",
                   help="Get the highest reported board temperature "
                        "from all sensors in Celsius.")
args = argparser.add_argument("-v", "--verbose",
                              action="store_true",
                              help="Show temperature type and value.")
argparser.set_defaults(temperature_type='all')
args = argparser.parse_args()

import common
from autotest_lib.client.bin import utils

TEMPERATURE_TYPE = {
    'Maximum': utils.get_current_temperature_max,
}

def print_temperature(temperature_type):
    if args.verbose:
        print(temperature_type, end=' ')
    print(TEMPERATURE_TYPE.get(temperature_type)())

if args.temperature_type == 'all':
    for temperature_type in list(TEMPERATURE_TYPE.keys()):
        print_temperature(temperature_type)
else:
    print_temperature(args.temperature_type)