From aafd67f2d592799167864698ea07eb8aadcc86a7 Mon Sep 17 00:00:00 2001 From: Samo Penic <samo.penic@gmail.com> Date: Wed, 25 May 2016 18:37:21 +0000 Subject: [PATCH] Merge branch 'master' of bitbucket.org:samop/trisurf-ng with work done on removing the memory leaks. --- python/trisurf/tsmgr.py | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-) diff --git a/python/trisurf/tsmgr.py b/python/trisurf/tsmgr.py index 164dadf..fa7d20f 100644 --- a/python/trisurf/tsmgr.py +++ b/python/trisurf/tsmgr.py @@ -1,5 +1,7 @@ import sys, getopt import tabulate +import subprocess,re +import psutil def printHelp(): print('Python module tsmgr accept following switches:\n') @@ -8,17 +10,28 @@ print('[-R] : raw output for -s switch'); print('[-r] : run process'); print('[-s] : process status'); + print('[-k] : kill process'); print('[-c comment text] : write new comment for process'); print('[-a comment text] : append additional comment for process'); print('[-h] : print help'); + +def getTrisurfVersion(): + p = subprocess.Popen('trisurf --version', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + lines=p.stdout.readlines() + version=re.findall(r'[0-9a-f]{7}(?:-dirty)?', lines[0].decode('ascii')) + p.wait() + if(len(version)): + return version[0] + else: + return "unknown version" def start(Runs): argv=sys.argv[1:] processno=0 raw=False try: - opts, args = getopt.getopt(argv,"Ra:n:hrsc:") + opts, args = getopt.getopt(argv,"Ra:n:hrskc:") except getopt.GetoptError: printHelp() sys.exit(2) @@ -65,7 +78,9 @@ if processno: Runs[processno-1].writeComment("\n"+arg, 'a') - + elif opt == '-k': + if processno: + Runs[processno-1].stop() else: printHelp() sys.exit(2) -- Gitblit v1.9.3