From a3f6b73f3f829a7abf3faa0e5e96d95200179529 Mon Sep 17 00:00:00 2001
From: Samo Penic <samo.penic@gmail.com>
Date: Sun, 15 May 2016 19:20:59 +0000
Subject: [PATCH] Added function that finds trisurf version from its executable output string. It can be used for outputting info

---
 python/myTestConfig.py  |    3 +++
 python/trisurf/tsmgr.py |   11 +++++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/python/myTestConfig.py b/python/myTestConfig.py
index d7c9360..e259078 100755
--- a/python/myTestConfig.py
+++ b/python/myTestConfig.py
@@ -3,6 +3,9 @@
 from trisurf import trisurf
 
 
+
+print("Running trisurf version "+ tsmgr.getTrisurfVersion())
+
 #Simple example how to start simulation from a previos snapshot
 run1=trisurf.Runner(snapshot='snapshot.vtu')
 run1.setMaindir(("N","k","V","Np","Nm"),("nshell","xk0","constvolswitch","npoly","nmono"))
diff --git a/python/trisurf/tsmgr.py b/python/trisurf/tsmgr.py
index 164dadf..adef0b2 100644
--- a/python/trisurf/tsmgr.py
+++ b/python/trisurf/tsmgr.py
@@ -1,5 +1,6 @@
 import sys, getopt
 import tabulate
+import subprocess,re
 
 def printHelp():
 	print('Python module tsmgr accept following switches:\n')
@@ -13,6 +14,16 @@
 	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

--
Gitblit v1.9.3