post_build_movie.py 1.69 KB
Newer Older
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
1
2
3
4
#!/usr/bin/env python
from __future__ import print_function
import sys
#sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
5
from unsiotools.simulations.cmovie import *
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
6
7
8
9
import argparse


# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
10
# commandLine, parse the command line
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
11
12
13
14
15
16
17
def commandLine():
    dbname=None

    # help
    parser = argparse.ArgumentParser(description="Build simulation movie after smart analysis",
                                    formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    # options
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
18

LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
19
20
21
22
23
24
25
26
27
    parser.add_argument('simname', help='Simulation name')

    parser.add_argument('--dbname',help='UNS database file name', default=dbname)
    parser.add_argument('--verbose',help='verbose mode on', dest="verbose", action="store_true", default=False)
    parser.add_argument('--overwrite',help='overwrite file if exist', dest="overwrite", action="store_true", default=False)
    parser.add_argument('--ncores', help='#cores used, 0 means all',default=4,type=int)
    #parser.add_argument('--no-verbose',help='verbose mode off', dest="verbose", action="store_false", default=True)

    # parse
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
28
    args = parser.parse_args()
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

    # start main funciton
    process(args)


# -----------------------------------------------------
# process, is the core function
def process(args):
    movie = CMovie(verbose_debug=args.verbose)
    try:
        movie.buildMovie(args.simname,args.overwrite,args.ncores)
        pass
    except Exception as x :
        print(x.message)
        sys.exit()

LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
45

LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
46
47
48
49
50

# -----------------------------------------------------
# main program
if __name__ == '__main__':
    commandLine()