Trisurf Monte Carlo simulator
Samo Penic
2016-05-13 9f5ff50a40f78ecdf25ec6bcd4e5490152db81d6
commit | author | age
9f5ff5 1 import sys, getopt
SP 2 import tabulate
3
4 def start(Runs):
5     argv=sys.argv[1:]
6     processno=0
7     try:
8         opts, args = getopt.getopt(argv,"a:n:hrsc:")
9     except getopt.GetoptError:
10         print('tsmgr [-n process number] [-h] [-r] [-s] [-c comment text] [-a comment text]')
11         sys.exit(2)
12     for opt, arg in opts:
13         if opt == '-h':
14             print ('tsmgr [-n process number] [-h] [-r] [-s] [-c comment text] [-a comment text]')
15             sys.exit()
16         elif opt == '-r':
17             if processno:
18                 localRuns=[Runs[processno-1]]
19             else:
20                 localRuns=Runs
21             for run in localRuns:
22                 run.start()
23         elif opt == '-s':
24             report=[]
25             i=1
26             if processno:
27                 localRuns=[Runs[processno-1]]
28             else:
29                 localRuns=Runs
30             for run in localRuns:
31                 line=run.getStatistics()
32                 line.insert(0,i)
33                 report.append(line)
34                 i=i+1
35                 #print(reportstr)
36             print ("\n\nTrisurf running processes report\n")
37             print (tabulate.tabulate(report,headers=["Run no.", "Run start time", "ETA", "Status", "PID", "Path", "Comment"], tablefmt='fancy_grid'))
38         elif opt == '-n':
39             processno=int(arg)
40             if processno<1 or processno>len(Runs) :
41                 processno=0
42         elif opt == '-c':
43             comment = arg
44             if processno:
45                 Runs[processno-1].writeComment(arg)
46         elif opt == '-a':
47             comment = arg
48             if processno:
49                 Runs[processno-1].writeComment("\n"+arg, 'a')
50
51             
52         else:
53             print('tsmgr [-n process number] [-h] [-r] [-s] [-c comment text] [-a comment text]')
54             sys.exit(2)
55
56
57
58
59
60