Statistics
| Branch: | Revision:

mobicen / mobiExp.py @ 05763cfb

History | View | Annotate | Download (1.74 KB)

1
import getopt
2
import code  # code.interact(local=dict(globals(), **locals()))
3
from pprint import pprint
4
import sys
5
import os
6
import shutil
7
import datetime
8
from simulator import Simulator
9

    
10
if __name__ == '__main__':
11
    
12
    settingsFile = ''
13
    sectionExp = ''
14
    outPath = ''
15
    cdir = ''
16
    num_workers = 1
17
    gui = False
18
    options, remainder = getopt.getopt(
19
        sys.argv[1:], '', ['sf=', 'en=', 'out=', 'thr=', 'gui'])
20
    mand = set(['--sf', '--en', '--out'])
21
    opts = [x[0] for x in options]
22
    # print 'OPTIONS   :', opts
23
    if (not mand.issubset(opts)):
24
        print 'Mandatory args are: --sf (settings file) --en (experiment name)'\
25
            ' --out (Output path, overwrite or create folder)'
26
        sys.exit(1)
27
    for opt, arg in options:
28
        if opt in ('--sf'):
29
            settingsFile = arg
30
        if opt in ('--en'):
31
            sectionExp = arg
32
        if opt in ('--thr'):
33
            num_workers = int(arg)
34
        if opt in ('--out'):
35
            outPath = arg
36
            outPath.rstrip("/")
37
            if not os.path.exists(outPath):
38
                sys.stderr.write("Cannot find the outpath you provided!")
39
                sys.exit(1)
40
            else:
41
                start = datetime.datetime.now().strftime("%Hh%Mm%Ss_%d-%m-%Y")
42
                cdir = outPath + '/' + sectionExp + '_'+ start
43
                if os.path.exists(cdir):
44
                    shutil.rmtree(cdir)
45
                os.makedirs(cdir)
46
                os.makedirs(cdir+'/topos')
47
        if opt in ('--gui'):
48
            gui = True
49

    
50
    sim = Simulator(settingsFile, sectionExp, cdir, num_workers=num_workers, gui=gui)
51
    print "Simulation Parameters\n"
52
    pprint(sim.params)
53
    #code.interact(local=dict(globals(), **locals()))
54
    sim.runSimulation()