~1chb1n/mojo/venv-friendly

« back to all changes in this revision

Viewing changes to mojo/juju/parse_status.py

[pjdc,r=mthaddon] add command_timeout to Juju1Status and Jujus2Status, and use it for juju-parse-status; lp#1641471

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
def main():
58
58
 
59
59
    parser = argparse.ArgumentParser(description="Provides convenience commands for parsing Juju2 status.")
60
 
    parser.add_argument("-f", "--file", dest="status_file", help="A yaml status file, if unspecified status is" +
61
 
                                                                 "pulled from the environment.")
 
60
    parser.add_argument("-f", "--file", dest="status_file",
 
61
                        help="A yaml status file; if unspecified, status is pulled from the environment.")
 
62
 
 
63
    parser.add_argument("-t", "--command-timeout", type=int, default=300,
 
64
                        help="Kill 'juju status' and give up if this amount of time elapses.")
62
65
 
63
66
    sp = parser.add_subparsers(title="", dest="status_info")
64
67
 
73
76
    if args.status_file is not None:
74
77
        with open(args.status_file, 'r') as sf:
75
78
            status_yaml = sf.read()
76
 
        status = Juju2Status(status_yaml=status_yaml)
 
79
        status = Juju2Status(status_yaml=status_yaml, command_timeout=args.command_timeout)
77
80
    else:
78
 
        status = Juju2Status()
 
81
        status = Juju2Status(command_timeout=args.command_timeout)
79
82
 
80
83
    print(available_info[args.status_info](status).run(args))
81
84
    return 0