Revision fa4a0a42 mobiExp.py

View differences:

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

  
7 10
if __name__ == '__main__':
8

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

  
27
    sim = Simulator(settingsFile, sectionExp, gui)
46
    sim = Simulator(settingsFile, sectionExp, cdir, gui)
28 47
    print "Simulation Parameters\n"
29 48
    pprint(sim.params)
30 49
    #code.interact(local=dict(globals(), **locals()))

Also available in: Unified diff