Trisurf Monte Carlo simulator
Samo Penic
2016-05-15 bb207499ba467145aabb379b841094afd6d695c0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import sys, getopt
import tabulate
 
def start(Runs):
    argv=sys.argv[1:]
    processno=0
    try:
        opts, args = getopt.getopt(argv,"a:n:hrsc:")
    except getopt.GetoptError:
        print('tsmgr [-n process number] [-h] [-r] [-s] [-c comment text] [-a comment text]')
        sys.exit(2)
    for opt, arg in opts:
        if opt == '-h':
            print ('tsmgr [-n process number] [-h] [-r] [-s] [-c comment text] [-a comment text]')
            sys.exit()
        elif opt == '-r':
            if processno:
                localRuns=[Runs[processno-1]]
            else:
                localRuns=Runs
            for run in localRuns:
                run.start()
        elif opt == '-s':
            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)
        elif opt == '-a':
            comment = arg
            if processno:
                Runs[processno-1].writeComment("\n"+arg, 'a')
 
            
        else:
            print('tsmgr [-n process number] [-h] [-r] [-s] [-c comment text] [-a comment text]')
            sys.exit(2)