[Swift-commit] r4938 - in SwiftApps/GOSwift: bin pykoa/tools
jonmon at ci.uchicago.edu
jonmon at ci.uchicago.edu
Wed Aug 3 15:52:04 CDT 2011
Author: jonmon
Date: 2011-08-03 15:52:04 -0500 (Wed, 03 Aug 2011)
New Revision: 4938
Added:
SwiftApps/GOSwift/bin/koa-goswift-manage
SwiftApps/GOSwift/pykoa/tools/koa_goswift_manage.py
Removed:
SwiftApps/GOSwift/bin/koa-goswift-kill
Log:
o commit files for the goswift_manage command. Resume is not implemented and stop is broken.
Deleted: SwiftApps/GOSwift/bin/koa-goswift-kill
===================================================================
--- SwiftApps/GOSwift/bin/koa-goswift-kill 2011-08-03 14:22:32 UTC (rev 4937)
+++ SwiftApps/GOSwift/bin/koa-goswift-kill 2011-08-03 20:52:04 UTC (rev 4938)
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-if [ -z "$KOA_HOME" ]; then
- echo "Error: KOA_HOME must be set"
- exit 1
-fi
-
-if [ -s "$KOA_USER" ]; then
- echo "Error: KOA_USER must be set"
- exit 1
-fi
-
-export KOA_API_11=TRUE
-
-exec $KOA_HOME/pykoa/tools/koa_goswift_kill.py "$@"
\ No newline at end of file
Copied: SwiftApps/GOSwift/bin/koa-goswift-manage (from rev 4937, SwiftApps/GOSwift/bin/koa-goswift-kill)
===================================================================
--- SwiftApps/GOSwift/bin/koa-goswift-manage (rev 0)
+++ SwiftApps/GOSwift/bin/koa-goswift-manage 2011-08-03 20:52:04 UTC (rev 4938)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+if [ -z "$KOA_HOME" ]; then
+ echo "Error: KOA_HOME must be set"
+ exit 1
+fi
+
+if [ -s "$KOA_USER" ]; then
+ echo "Error: KOA_USER must be set"
+ exit 1
+fi
+
+export KOA_API_11=TRUE
+
+exec $KOA_HOME/pykoa/tools/koa_goswift_kill.py "$@"
\ No newline at end of file
Added: SwiftApps/GOSwift/pykoa/tools/koa_goswift_manage.py
===================================================================
--- SwiftApps/GOSwift/pykoa/tools/koa_goswift_manage.py (rev 0)
+++ SwiftApps/GOSwift/pykoa/tools/koa_goswift_manage.py 2011-08-03 20:52:04 UTC (rev 4938)
@@ -0,0 +1,64 @@
+import os
+import sys
+import commands
+
+import pykoa
+import pykoa.tools
+from pykoa.koaexception import cli_exception_handler
+
+def setup_opts(argv):
+ help_screen = """
+goswift_manage [option] <run-number>
+
+Stop a currently running run or resume a stopped run.
+
+Type 'man goswift_manage' for details. \
+"""
+
+ parser = pykoa.tools.get_option_parser(help_screen)
+ parser.add_option("--stop", dest="stop",
+ default=False, action="store_true",
+ help="Stop/resume a run my the run id")
+
+ (options, args) pykoa.tools.parse_args(parser, argv)
+
+ return (parser, options, args)
+
+def stop(run_id):
+ user = os.environ["USER"]
+ (status, output) = commands.getstatusoutput("ps -u "+user+" -f")
+ if status != 0:
+ sys.stderr.write("Failed to get a list of running processes\n")
+ return 1
+
+ ppid = ??
+ processes = [ppid]
+ lines = []
+ for line in ouput.split("\n"):
+ parsed_line = line.split(" ")
+ if ppid == parsed_line[2]:
+ processes.append(parsed_line[1])
+ ppid = int(parsed_line[1])
+
+ for pid in processes:
+ os.kill(pid, 9)
+
+ return 0
+
+ at cli_exception_handler
+def main( argv=sys.argv[1:] ):
+ (parser, options, args) = setup_opts(argv)
+ ret = -1
+
+ if len(args) != 1:
+ parser.print_help()
+ return 1
+
+ if options.stop:
+ ret = stop(args[0])
+
+ return ret
+
+if __name__ == "__main__":
+ rc = main()
+ sys.exit(rc)
Property changes on: SwiftApps/GOSwift/pykoa/tools/koa_goswift_manage.py
___________________________________________________________________
Added: svn:executable
+ *
More information about the Swift-commit
mailing list