Permalink
Browse files

Added optional --write-report flag for find-versions action

  • Loading branch information...
1 parent 4b27160 commit c2d2659c3c4300c7253f5626ac17782e280f3444 @timf timf committed Sep 19, 2011
Showing with 14 additions and 0 deletions.
  1. +4 −0 src/python/epumgmt/main/em_args.py
  2. +10 −0 src/python/epumgmt/main/em_core_versions.py
@@ -71,6 +71,10 @@
a.append(KILLRUN_NOFETCH)
KILLRUN_NOFETCH.help = "Can be used with action %s and %s. If used, does not try to find any new information or get any logs." % (ACTIONS.KILLRUN, ACTIONS.FIND_VERSIONS)
+WRITE_REPORT = ControlArg("write-report", None, metavar="PATH")
+a.append(WRITE_REPORT)
+WRITE_REPORT.help = "Used with action %s. Also write report to the given path if it does not exist." % ACTIONS.FIND_VERSIONS
+
NEWN = ControlArg("newn", None)
a.append(NEWN)
NEWN.help = "Used with '--action %s'. Syntax is controller_name:N[,controller_name:N,...]" % ACTIONS.RECONFIGURE_N
@@ -1,4 +1,6 @@
from epumgmt.api.exceptions import IncompatibleEnvironment, UnexpectedError
+from epumgmt.main import em_args
+import os
FALSE_POSITIVES = ["site-packages", "python2.5", "python2.6", "bin", "plat-linux2", "app",
"lib-old", "lib-tk", "lib-dynload"]
@@ -15,6 +17,14 @@ def print_versions(p, c, m, run_name):
txt = _vnode_report(vnodes, counts)
print ""
print txt
+ report_path = p.get_arg_or_none(em_args.WRITE_REPORT)
+ if report_path:
+ if os.path.exists(report_path):
+ raise IncompatibleEnvironment("Can not write report to pre-existing file: %s" % report_path)
+ f = open(report_path, mode='w')
+ f.write(txt)
+ f.close()
+ print "Wrote report to: %s" % report_path
def _vnode_report(vnodes, counts):
if len(vnodes) == 1:

0 comments on commit c2d2659

Please sign in to comment.