[haizea-commit] r484 - in trunk: doc/manual src/haizea/cli
haizea-commit at mailman.cs.uchicago.edu
haizea-commit at mailman.cs.uchicago.edu
Mon Sep 1 06:26:33 CDT 2008
Author: borja
Date: 2008-09-01 06:26:33 -0500 (Mon, 01 Sep 2008)
New Revision: 484
Added:
trunk/doc/manual/gen_cli_doc.py
Modified:
trunk/src/haizea/cli/commands.py
trunk/src/haizea/cli/rpc_commands.py
Log:
Generate CLI documentation in LaTeX automatically
Added: trunk/doc/manual/gen_cli_doc.py
===================================================================
--- trunk/doc/manual/gen_cli_doc.py (rev 0)
+++ trunk/doc/manual/gen_cli_doc.py 2008-09-01 11:26:33 UTC (rev 484)
@@ -0,0 +1,31 @@
+import haizea.cli.commands as cmd
+import haizea.cli.rpc_commands as rpccmd
+from docutils.core import publish_string
+import re
+
+commands = [cmd.haizea, rpccmd.haizea_request_lease, rpccmd.haizea_cancel_lease, rpccmd.haizea_list_leases,
+ rpccmd.haizea_show_queue, rpccmd.haizea_list_hosts, cmd.haizea_generate_configs, cmd.haizea_generate_scripts, cmd.haizea_convert_data]
+
+
+
+for command in commands:
+ c = command([])
+ print "\\section{\\texttt{%s}}" % command.name
+ print
+ doc = command.__doc__
+ latexdoc = publish_string(doc, writer_name="latex")
+ latexdoc = re.compile("\\\\begin{document}\n\n\\\\setlength{\\\\locallinewidth}{\\\\linewidth}\n\n(.*)\\\\end{document}", flags=re.DOTALL).search(latexdoc)
+ print latexdoc.group(1)
+ print
+ print "\\begin{center}\\begin{tabular}{|l|p{6cm}|}"
+ print "\\hline"
+ print "\\sffamily\\bfseries Option & \\sffamily\\bfseries Description \\\\ \\hline\\hline"
+ opts = c.optparser.option_list
+ c.optparser.formatter.store_option_strings(c.optparser)
+ for opt in opts:
+ if opt.action != "help":
+ opt_string = c.optparser.formatter.option_strings[opt]
+ print "\\texttt{%s} & \\sffamily %s \\\\ \\hline" % (opt_string, opt.help)
+ print "\\end{tabular}\\end{center}"
+ print
+
\ No newline at end of file
Modified: trunk/src/haizea/cli/commands.py
===================================================================
--- trunk/src/haizea/cli/commands.py 2008-09-01 11:25:20 UTC (rev 483)
+++ trunk/src/haizea/cli/commands.py 2008-09-01 11:26:33 UTC (rev 484)
@@ -31,16 +31,29 @@
class haizea(Command):
+ """Documentation goes here"""
+
+ name = "haizea"
+
def __init__(self, argv):
Command.__init__(self, argv)
- self.optparser.add_option(Option("-c", "--conf", action="store", type="string", dest="conf"))
- self.optparser.add_option(Option("-f", "--fg", action="store_true", dest="foreground"))
- self.optparser.add_option(Option("--stop", action="store_true", dest="stop"))
-
+ self.optparser.add_option(Option("-c", "--conf", action="store", type="string", dest="conf",
+ help = """
+ Option documentation goes here
+ """))
+ self.optparser.add_option(Option("-f", "--fg", action="store_true", dest="foreground",
+ help = """
+ Option documentation goes here
+ """))
+ self.optparser.add_option(Option("--stop", action="store_true", dest="stop",
+ help = """
+ Option documentation goes here
+ """))
+
+ def run(self):
self.parse_options()
-
- def run(self):
+
pidfile = defaults.DAEMON_PIDFILE # TODO: Make configurable
if self.opt.stop == None:
@@ -115,15 +128,25 @@
sys.exit(1)
class haizea_generate_configs(Command):
+ """Documentation goes here"""
+
+ name = "haizea-generate-configs"
+
def __init__(self, argv):
Command.__init__(self, argv)
- self.optparser.add_option(Option("-c", "--conf", action="store", type="string", dest="conf", required=True))
- self.optparser.add_option(Option("-d", "--dir", action="store", type="string", dest="dir", required=True))
-
+ self.optparser.add_option(Option("-c", "--conf", action="store", type="string", dest="conf", required=True,
+ help = """
+ Option documentation goes here
+ """))
+ self.optparser.add_option(Option("-d", "--dir", action="store", type="string", dest="dir", required=True,
+ help = """
+ Option documentation goes here
+ """))
+
+ def run(self):
self.parse_options()
- def run(self):
configfile=self.opt.conf
multiconfig = HaizeaMultiConfig.from_file(configfile)
@@ -146,17 +169,33 @@
fc.close()
class haizea_generate_scripts(Command):
+ """Documentation goes here"""
+
+ name = "haizea-generate-scripts"
+
def __init__(self, argv):
Command.__init__(self, argv)
- self.optparser.add_option(Option("-c", "--conf", action="store", type="string", dest="conf", required=True))
- self.optparser.add_option(Option("-t", "--template", action="store", type="string", dest="template", required=True))
- self.optparser.add_option(Option("-d", "--confdir", action="store", type="string", dest="confdir", required=True))
- self.optparser.add_option(Option("-m", "--only-missing", action="store_true", dest="onlymissing"))
-
+ self.optparser.add_option(Option("-c", "--conf", action="store", type="string", dest="conf", required=True,
+ help = """
+ Option documentation goes here
+ """))
+ self.optparser.add_option(Option("-t", "--template", action="store", type="string", dest="template", required=True,
+ help = """
+ Option documentation goes here
+ """))
+ self.optparser.add_option(Option("-d", "--confdir", action="store", type="string", dest="confdir", required=True,
+ help = """
+ Option documentation goes here
+ """))
+ self.optparser.add_option(Option("-m", "--only-missing", action="store_true", dest="onlymissing",
+ help = """
+ Option documentation goes here
+ """))
+
+ def run(self):
self.parse_options()
- def run(self):
configfile=self.opt.conf
multiconfig = HaizeaMultiConfig.from_file(configfile)
@@ -189,18 +228,37 @@
class haizea_convert_data(Command):
+ """Documentation goes here"""
+
+ name = "haizea-convert-data"
+
def __init__(self, argv):
Command.__init__(self, argv)
- self.optparser.add_option(Option("-d", "--datafiles", action="store", type="string", dest="datafiles", required=True))
- self.optparser.add_option(Option("-s", "--summary", action="store_true", dest="summary"))
- self.optparser.add_option(Option("-l", "--lease-stats", action="store", type="string", dest="lease"))
- self.optparser.add_option(Option("-t", "--include-attributes", action="store_true", dest="attributes"))
- self.optparser.add_option(Option("-f", "--format", action="store", type="string", dest="format"))
-
+ self.optparser.add_option(Option("-d", "--datafiles", action="store", type="string", dest="datafiles", required=True,
+ help = """
+ Option documentation goes here
+ """))
+ self.optparser.add_option(Option("-s", "--summary", action="store_true", dest="summary",
+ help = """
+ Option documentation goes here
+ """))
+ self.optparser.add_option(Option("-l", "--lease-stats", action="store", type="string", dest="lease",
+ help = """
+ Option documentation goes here
+ """))
+ self.optparser.add_option(Option("-t", "--include-attributes", action="store_true", dest="attributes",
+ help = """
+ Option documentation goes here
+ """))
+ self.optparser.add_option(Option("-f", "--format", action="store", type="string", dest="format",
+ help = """
+ Option documentation goes here
+ """))
+
+ def run(self):
self.parse_options()
-
- def run(self):
+
datafile=self.opt.datafiles
stats = unpickle(datafile)
Modified: trunk/src/haizea/cli/rpc_commands.py
===================================================================
--- trunk/src/haizea/cli/rpc_commands.py 2008-09-01 11:25:20 UTC (rev 483)
+++ trunk/src/haizea/cli/rpc_commands.py 2008-09-01 11:26:33 UTC (rev 484)
@@ -27,28 +27,62 @@
class RPCCommand(Command):
def __init__(self, argv):
Command.__init__(self, argv)
- self.optparser.add_option(Option("-s", "--server", action="store", type="string", dest="server", default=defaults.RPC_URI))
+ self.optparser.add_option(Option("-s", "--server", action="store", type="string", dest="server", default=defaults.RPC_URI,
+ help = """
+ Option documentation goes here
+ """))
def create_rpc_proxy(self, server):
return xmlrpclib.ServerProxy(server, allow_none=True)
class haizea_request_lease(RPCCommand):
+ """Documentation goes here"""
+
+ name = "haizea-request-lease"
+
def __init__(self, argv):
RPCCommand.__init__(self, argv)
- self.optparser.add_option(Option("-t", "--start", action="store", type="string", dest="start"))
- self.optparser.add_option(Option("-d", "--duration", action="store", type="string", dest="duration"))
- self.optparser.add_option(Option("-n", "--numnodes", action="store", type="int", dest="numnodes"))
- self.optparser.add_option(Option("--preemptible", action="store_true", dest="preemptible"))
- self.optparser.add_option(Option("--non-preemptible", action="store_false", dest="preemptible"))
- self.optparser.add_option(Option("-c", "--cpu", action="store", type="float", dest="cpu"))
- self.optparser.add_option(Option("-m", "--mem", action="store", type="int", dest="mem"))
- self.optparser.add_option(Option("-i", "--vmimage", action="store", type="string", dest="vmimage"))
- self.optparser.add_option(Option("-z", "--vmimagesize", action="store", type="int", dest="vmimagesize"))
+ self.optparser.add_option(Option("-t", "--start", action="store", type="string", dest="start",
+ help = """
+ Option documentation goes here
+ """))
+ self.optparser.add_option(Option("-d", "--duration", action="store", type="string", dest="duration",
+ help = """
+ Option documentation goes here
+ """))
+ self.optparser.add_option(Option("-n", "--numnodes", action="store", type="int", dest="numnodes",
+ help = """
+ Option documentation goes here
+ """))
+ self.optparser.add_option(Option("--preemptible", action="store_true", dest="preemptible",
+ help = """
+ Option documentation goes here
+ """))
+ self.optparser.add_option(Option("--non-preemptible", action="store_false", dest="preemptible",
+ help = """
+ Option documentation goes here
+ """))
+ self.optparser.add_option(Option("-c", "--cpu", action="store", type="float", dest="cpu",
+ help = """
+ Option documentation goes here
+ """))
+ self.optparser.add_option(Option("-m", "--mem", action="store", type="int", dest="mem",
+ help = """
+ Option documentation goes here
+ """))
+ self.optparser.add_option(Option("-i", "--vmimage", action="store", type="string", dest="vmimage",
+ help = """
+ Option documentation goes here
+ """))
+ self.optparser.add_option(Option("-z", "--vmimagesize", action="store", type="int", dest="vmimagesize",
+ help = """
+ Option documentation goes here
+ """))
+ def run(self):
self.parse_options()
- def run(self):
if self.opt.preemptible == None:
preemptible = False
else:
@@ -65,14 +99,21 @@
print >> sys.stderr, "Error: %s" % msg
class haizea_cancel_lease(RPCCommand):
+ """Documentation goes here"""
+
+ name = "haizea-cancel-lease"
+
def __init__(self, argv):
RPCCommand.__init__(self, argv)
- self.optparser.add_option(Option("-l", "--lease", action="store", type="int", dest="lease"))
+ self.optparser.add_option(Option("-l", "--lease", action="store", type="int", dest="lease",
+ help = """
+ Option documentation goes here
+ """))
+ def run(self):
self.parse_options()
- def run(self):
server = self.create_rpc_proxy(self.opt.server)
try:
@@ -81,12 +122,16 @@
print >> sys.stderr, "Error: %s" % msg
class haizea_list_leases(RPCCommand):
+ """Documentation goes here"""
+
+ name = "haizea-list-leases"
+
def __init__(self, argv):
RPCCommand.__init__(self, argv)
+ def run(self):
self.parse_options()
- def run(self):
server = self.create_rpc_proxy(self.opt.server)
fields = [("id","ID", 3),
@@ -103,12 +148,16 @@
print >> sys.stderr, "Error: %s" % msg
class haizea_list_hosts(RPCCommand):
+ """Documentation goes here"""
+
+ name = "haizea-list-hosts"
+
def __init__(self, argv):
RPCCommand.__init__(self, argv)
+ def run(self):
self.parse_options()
- def run(self):
server = self.create_rpc_proxy(self.opt.server)
fields = [("id","ID", 3),
@@ -123,12 +172,16 @@
print >> sys.stderr, "Error: %s" % msg
class haizea_show_queue(RPCCommand):
+ """Documentation goes here"""
+
+ name = "haizea-show-queue"
+
def __init__(self, argv):
RPCCommand.__init__(self, argv)
+ def run(self):
self.parse_options()
- def run(self):
server = self.create_rpc_proxy(self.opt.server)
fields = [("id","ID", 3),
More information about the Haizea-commit
mailing list