[Swift-commit] r4930 - SwiftApps/GOSwift/pykoa/tools
jonmon at ci.uchicago.edu
jonmon at ci.uchicago.edu
Tue Aug 2 11:11:11 CDT 2011
Author: jonmon
Date: 2011-08-02 11:11:11 -0500 (Tue, 02 Aug 2011)
New Revision: 4930
Modified:
SwiftApps/GOSwift/pykoa/tools/koa_goswift_stat.py
Log:
o fixed the '-n' option in koa_goswift_stat.py. Using the -n option now varies how many lines to be printed out from the log file or the swift.out file.
Modified: SwiftApps/GOSwift/pykoa/tools/koa_goswift_stat.py
===================================================================
--- SwiftApps/GOSwift/pykoa/tools/koa_goswift_stat.py 2011-08-02 15:44:33 UTC (rev 4929)
+++ SwiftApps/GOSwift/pykoa/tools/koa_goswift_stat.py 2011-08-02 16:11:11 UTC (rev 4930)
@@ -12,7 +12,7 @@
Checks the status of a run started in the background using goswift by reading the last n lines of the stdout/stderr file. Only 1 run is allowed to get the status of at a time.
-Default number of lines is 50.
+Default number of lines is 10.
Type 'man goswift_stat' for details. \
"""
@@ -20,8 +20,12 @@
parser = pykoa.tools.get_option_parser(help_screen)
parser.add_option("--debug", dest="debugging",
default=False, action="store_true",
- help="Get status from the last 50 lines of the Swift log file.")
+ help="Get status from the last 10 lines of the Swift log file.")
+ parser.add_option("-n", dest="lines",
+ default="10",
+ help="Set the number of lines to be printed out from the swift.out or log file.")
+
(options, args) = pykoa.tools.parse_args(parser, argv)
return (parser, options, args)
@@ -56,13 +60,19 @@
sys.stderr.write( run_dir+" does not exist!\n" )
return 1
+ try:
+ int(options.lines)
+ except ValueError:
+ sys.stderr.write("Invalid value for '-n': '"+options.lines+"'\n")
+ return 1
+
# output from the log file if the log file exists
if options.debugging:
if not os.access( run_dir+"/script-"+args[0]+".log", os.F_OK):
sys.stderr.write( run_dir+"/script-"+args[0]+".log does not exitst!\n" )
return 1
- cmd = "tail -"+str(50)+" "+run_dir+"/script-"+args[0]+".log"
+ cmd = "tail -"+str(options.lines)+" "+run_dir+"/script-"+args[0]+".log"
status = subprocess.call( cmd, close_fds=True,
shell=True )
# output from the swift.out file if it exists
@@ -71,7 +81,7 @@
sys.stderr.write( run_dir+"/swift.out does not exitst!\n" )
return 1
- cmd = "tail -"+str(50)+" "+run_dir+"/swift.out"
+ cmd = "tail -"+str(options.lines)+" "+run_dir+"/swift.out"
status = subprocess.call( cmd, close_fds=True,
shell=True )
More information about the Swift-commit
mailing list