Home | History | Annotate | Download | only in utils
      1 #!/usr/bin/python
      2 """
      3 Read a variable in the global config for autotest
      4 i.e. SCHEDULER.drones TKO.host
      5 """
      6 
      7 import sys
      8 import common
      9 from autotest_lib.client.common_lib import global_config
     10 
     11 
     12 def usage():
     13     print ("Usage: ./read_var_config.py SECTION.variable.\n"
     14            "e.g. ./read_var_config.py SCHEDULER.drones TKO.host.\n")
     15     sys.exit(1)
     16 
     17 def main(args):
     18 
     19     if len(args) <= 1:
     20         usage()
     21 
     22     entries = args[1:]
     23 
     24     for entry in entries:
     25         try:
     26             section, var = entry.split('.')
     27         except ValueError:
     28             print "Invalid SECTION.varable supplied: " + entry
     29             usage()
     30 
     31         try:
     32             print global_config.global_config.get_config_value(section, var)
     33         except global_config.ConfigError:
     34             print "Error reading %s.%s" % (section, var)
     35 
     36 
     37 if __name__ == '__main__':
     38     main(sys.argv)
     39