#!/usr/bin/env python3 import sys import configtools if __name__ == "__main__": opts, args = configtools.parse_args( configtools.options, usage="Usage: getconf.py [options] <item>|-a <section> [<section> ...]", ) conf, files = configtools.init(opts, "_PBENCH_SERVER_CONFIG") status = configtools.main(conf, args, opts, files) sys.exit(status)
help="print everything"), make_option("-l", "--list", action="store_true", dest="list", help="print it as a shell list, translating commas to spaces"), make_option("-L", "--listfiles", action="store_true", dest="listfiles", help="print the list of config files"), ] if __name__ == '__main__': opts, args = configtools.parse_args( options, usage='Usage: getconf.py [options] <item>|-a <section> [<section> ...]' ) conf, files = configtools.init(opts) if not conf: sys.exit(1) if opts.listfiles: files.reverse() print(files) sys.exit(0) if args: status = main(conf, args, opts) else: status = 1 sys.exit(status)
#!/usr/bin/env python3 import sys import configtools if __name__ == "__main__": opts, args = configtools.parse_args( configtools.options, usage="Usage: getconf.py [options] <item>|-a <section> [<section> ...]", ) conf, files = configtools.init(opts, "_PBENCH_AGENT_CONFIG") status = configtools.main(conf, args, opts, files) sys.exit(status)
return 0 # hosts in a single class if opts.listclass in hostclasses: hosts = configtools.get_list(conf.get("hosts", opts.listclass)) configtools.print_list(hosts, sep) return 0 # otherwise all the args should be classes: gather up their hosts: hosts = [] for a in args: if a in hostclasses: hosts.extend(configtools.get_list(conf.get("hosts", a))) else: return 1 configtools.print_list(hosts, sep) return 0 options = [ make_option("-a", "--all", action="store_true", dest="all", help="print all hosts in all classes"), make_option("-l", "--list", action="store_true", dest="list", help="print it as a shell list, translating commas to spaces"), make_option("-L", "--listclasses", action="store_true", dest="listclasses", help="print the list of host classes"), make_option("-c", "--class", action="store", dest="listclass", help="print the list of hosts in a host class"), ] if __name__ == '__main__': opts, args = configtools.parse_args(options) conf, files = configtools.init(opts) status = main(conf, args, opts) sys.exit(status)