Trisurf Monte Carlo simulator
Samo Penic
2016-03-16 9154b3cc571c2461010573f84b91fcf84830cf5a
python/tsmgr
@@ -1,6 +1,7 @@
#!/usr/bin/python3
import sys, getopt
from trisurf import trisurf
import tabulate
# -- configuration of the multiple/single run --
@@ -14,30 +15,58 @@
#obligatory: combine all runs
Runs=[run1,run2];
Runs=[run1,run2]
#------------------ NO NEED TO TOUCH THE CODE BELOW ------------------------------
# -- reading command line switches and acting accordingly --
argv=sys.argv[1:];
argv=sys.argv[1:]
processno=0
try:
   opts, args = getopt.getopt(argv,"hrs")
   opts, args = getopt.getopt(argv,"n:hrsc:")
except getopt.GetoptError:
   print('tsmgr [-h] [-r] [-s]')
   print('tsmgr [-n process number] [-h] [-r] [-s] [-c comment text]')
   sys.exit(2)
for opt, arg in opts:
   if opt == '-h':
      print ('tsmgr [-h] [-r] [-s]')
      print ('tsmgr [-n process number] [-h] [-r] [-s] [-c comment text]')
      sys.exit()
   elif opt == '-r':
      for run in Runs:
      if processno:
         localRuns=[Runs[processno-1]]
      else:
         localRuns=Runs
      for run in localRuns:
         run.start()
   elif opt == '-s':
      for run in Runs:
         reportstr=run.getStatistics()
         print(reportstr)
         #print(run)
         #print(run.statistics)
      report=[]
      i=1
      if processno:
         localRuns=[Runs[processno-1]]
      else:
         localRuns=Runs
      for run in localRuns:
         line=run.getStatistics()
         line.insert(0,i)
         report.append(line)
         i=i+1
         #print(reportstr)
      print ("\n\nTrisurf running processes report\n")
      print (tabulate.tabulate(report,headers=["Run no.", "Run start time", "ETA", "Status", "PID", "Path", "Comment"], tablefmt='fancy_grid'))
   elif opt == '-n':
      processno=int(arg)
      if processno<1 or processno>len(Runs) :
         processno=0
   elif opt == '-c':
      comment = arg
      if processno:
         Runs[processno-1].writeComment(arg)
   else:
      print('tsmgr [-h] [-r] [-s]')
      print('tsmgr [-n process number] [-h] [-r] [-s] [-c comment text]')
      sys.exit(2)