repository: /home/avi/kvm branch: master commit 14892fe1817712ff8555a9de474165e9d38d1b90 Author: Avi Kivity <[EMAIL PROTECTED]> Date: Sun Nov 18 14:09:45 2007 +0200
kvm: stats: batch mode Signed-off-by: Avi Kivity <[EMAIL PROTECTED]> diff --git a/kvm_stat b/kvm_stat index 5b27a75..9217939 100755 --- a/kvm_stat +++ b/kvm_stat @@ -1,7 +1,7 @@ #!/usr/bin/python import curses -import sys, os, time +import sys, os, time, optparse class Stats: def __init__(self): @@ -31,7 +31,7 @@ stats = Stats() label_width = 20 number_width = 10 -def main(screen, stats): +def tui(screen, stats): curses.use_default_colors() curses.noecho() def refresh(): @@ -62,8 +62,26 @@ def main(screen, stats): break except curses.error: continue - -import curses.wrapper -curses.wrapper(main, stats) +def batch(stats): + s = stats.get() + time.sleep(1) + s = stats.get() + for key in sorted(s.keys()): + values = s[key] + print '%-22s%10d%10d' % (key, values[0], values[1]) +options = optparse.OptionParser() +options.add_option('-1', '--once', '--batch', + action = 'store_true', + default = False, + dest = 'once', + help = 'run in batch mode for one second', + ) +(options, args) = options.parse_args(sys.argv) + +if not options.once: + import curses.wrapper + curses.wrapper(tui, stats) +else: + batch(stats) ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ kvm-commits mailing list kvm-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-commits