pynemo_exe.py 1.34 KB
Newer Older
James Harle's avatar
James Harle committed
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
'''
Entry for the project

@author: Mr. Srikanth Nagella
'''

import sys, getopt
import profile
import logging

# Logging set to info
logging.basicConfig(level=logging.INFO)
import time
def main():
    """ Main function which checks the command line parameters and
        passes them to the profile module for processing """

    setup_file = ''
    mask_gui = False
    try:
        opts, dummy_args = getopt.getopt(sys.argv[1:], "hs:g", ["help","setup=","mask_gui"])
    except getopt.GetoptError:
        print "usage: pynemo -g -s <namelist.bdy> "
        sys.exit(2)

    for opt, arg in opts:
        if opt == "-h":
            print "usage: pynemo [-g] -s <namelist.bdy> "
            print "       -g (optional) will open settings editor before extracting the data"
            print "       -s <bdy filename> file to use"
            sys.exit()
        elif opt in ("-s", "--setup"):
            setup_file = arg
        elif opt in("-g", "--mask_gui"):
            mask_gui = True

    if setup_file == "":
        print "usage: pynemo [-g] -s <namelist.bdy> "
        sys.exit(2)

    #Logger
    #logger = logging.getLogger(__name__)
    t0 = time.time()
    profile.process_bdy(setup_file, mask_gui)
    t1 = time.time()
    print "Execution Time: %s" % (t1-t0)
    
if __name__ == "__main__":
    main()