1#!/usr/bin/env python 2 3import argparse 4 5argparser = argparse.ArgumentParser( 6 description="Get the highest reported board temperature (all sensors) in " 7 "Celsius.") 8 9group = argparser.add_mutually_exclusive_group() 10group.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.") 16group.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.") 22args = argparser.add_argument("-v", "--verbose", 23 action="store_true", 24 help="Show temperature type and value.") 25argparser.set_defaults(temperature_type='all') 26args = argparser.parse_args() 27 28import common 29from autotest_lib.client.bin import utils 30 31TEMPERATURE_TYPE = { 32 'Critical': utils.get_temperature_critical, 33 'Maximum': utils.get_current_temperature_max, 34} 35 36def print_temperature(temperature_type): 37 if args.verbose: 38 print temperature_type, 39 print TEMPERATURE_TYPE.get(temperature_type)() 40 41if args.temperature_type == 'all': 42 for temperature_type in TEMPERATURE_TYPE.keys(): 43 print_temperature(temperature_type) 44else: 45 print_temperature(args.temperature_type) 46