Mike Frysinger | d03e6b5 | 2019-08-03 12:49:01 -0400 | [diff] [blame^] | 1 | #!/usr/bin/env python2 |
Po-Hsien Wang | 6dadbab | 2017-05-08 15:56:10 -0700 | [diff] [blame] | 2 | |
| 3 | import argparse |
| 4 | |
| 5 | argparser = argparse.ArgumentParser( |
| 6 | description="Get the highest reported board temperature (all sensors) in " |
| 7 | "Celsius.") |
| 8 | |
| 9 | group = argparser.add_mutually_exclusive_group() |
| 10 | group.add_argument("-m", "--maximum", |
| 11 | action="store_const", |
| 12 | const='Maximum', |
| 13 | dest="temperature_type", |
| 14 | help="Get the highest reported board temperature " |
| 15 | "from all sensors in Celsius.") |
| 16 | group.add_argument("-c", "--critical", |
| 17 | action="store_const", |
| 18 | const="Critical", |
| 19 | dest="temperature_type", |
| 20 | help="Get the critical temperature from all " |
| 21 | "sensors in Celsius.") |
| 22 | args = argparser.add_argument("-v", "--verbose", |
| 23 | action="store_true", |
| 24 | help="Show temperature type and value.") |
| 25 | argparser.set_defaults(temperature_type='all') |
| 26 | args = argparser.parse_args() |
| 27 | |
| 28 | import common |
| 29 | from autotest_lib.client.bin import utils |
| 30 | |
| 31 | TEMPERATURE_TYPE = { |
| 32 | 'Critical': utils.get_temperature_critical, |
| 33 | 'Maximum': utils.get_current_temperature_max, |
| 34 | } |
| 35 | |
| 36 | def print_temperature(temperature_type): |
| 37 | if args.verbose: |
| 38 | print temperature_type, |
| 39 | print TEMPERATURE_TYPE.get(temperature_type)() |
| 40 | |
| 41 | if args.temperature_type == 'all': |
| 42 | for temperature_type in TEMPERATURE_TYPE.keys(): |
| 43 | print_temperature(temperature_type) |
| 44 | else: |
| 45 | print_temperature(args.temperature_type) |