[Swift-commit] r4945 - SwiftApps/GOSwift/pykoa/tools
jonmon at ci.uchicago.edu
jonmon at ci.uchicago.edu
Thu Aug 4 16:30:54 CDT 2011
Author: jonmon
Date: 2011-08-04 16:30:54 -0500 (Thu, 04 Aug 2011)
New Revision: 4945
Modified:
SwiftApps/GOSwift/pykoa/tools/koa_goswift_manage.py
Log:
o Changed the 'ps -u $USER -f' to 'ps -u $USER -H -f'
o Added get the Swift pid from the swift.info file
o Getting list of processes to kill is broken. Don't parse the lines from the 'ps' output correctly.
Modified: SwiftApps/GOSwift/pykoa/tools/koa_goswift_manage.py
===================================================================
--- SwiftApps/GOSwift/pykoa/tools/koa_goswift_manage.py 2011-08-04 20:02:30 UTC (rev 4944)
+++ SwiftApps/GOSwift/pykoa/tools/koa_goswift_manage.py 2011-08-04 21:30:54 UTC (rev 4945)
@@ -20,22 +20,34 @@
default=False, action="store_true",
help="Stop/resume a run my the run id")
- (options, args) pykoa.tools.parse_args(parser, argv)
+ (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")
+ (status, output) = commands.getstatusoutput("ps -u "+user+" -H -f")
if status != 0:
sys.stderr.write("Failed to get a list of running processes\n")
return 1
- ppid = ??
+ ppid = -1
+
+ with open(os.environ["HOME"]+"/Swift/run."+run_id+"/swift.info") as swift_info:
+ for line in swift_info.readlines():
+ line_parsed = line.split(":")
+ if line_parsed[0] == "Swift pid":
+ ppid = int(line_parsed[1].strip())
+ break
+
+ if ppid == -1:
+ sys.stderr.write("Could not find the Swift pid from the swift.info file\n")
+ return 1
+
processes = [ppid]
- lines = []
- for line in ouput.split("\n"):
- parsed_line = line.split(" ")
+ # BROKEN: Doesn't parse the 'ps' output correctly. Fix the 'parsed_line' split delimiter
+ for line in output.split("\n"):
+ parsed_line = line.split()
if ppid == parsed_line[2]:
processes.append(parsed_line[1])
ppid = int(parsed_line[1])
More information about the Swift-commit
mailing list