def main(argv=None):
    """Main processing script for all maps """

    elog.elog_init(sys.argv)
    elog.elog_notify("Start of script")

    verbose, debug, year, month, maptype, deploytype, size = process_command_line(argv)
        
    if debug:
        elog.elog_notify("*** DEBUGGING ON ***")
        elog.elog_notify("*** No grd or grad files - just single color for speed ***")

    common_pf = 'common.pf'
    stations_pf = 'stations.pf'

    elog.elog_notify(" - Creating **%s** maps" % deploytype)
    if verbose:
        elog.elog_notify(" - Parse configuration parameter file (%s)" % common_pf)
        elog.elog_notify(" - Parse stations parameter file (%s)" % stations_pf)

    wet_rgb = '202/255/255'

    pfupdate(common_pf)
    pfupdate(stations_pf)

    dbmaster = pfget(common_pf, 'USARRAY_DBMASTER')
    networks = pfget_arr(stations_pf, 'network')
    infrasound = pfget_arr(stations_pf, 'infrasound')
    colors = pfget_arr(stations_pf, 'colors')
    # Force the tmp dir environmental variable
    tmp = pfget(common_pf, 'TMP')
    os.environ['TMPDIR'] = os.environ['TEMP'] = os.environ['TMP'] = tmp
    gmtbindir = pfget(common_pf, 'GMT_BIN')
    usa_coords = pfget_arr(common_pf, 'USACOORDS')
    ak_coords = pfget_arr(common_pf, 'AKCOORDS')
    web_output_dir = pfget(common_pf, 'CACHE_MONTHLY_DEPLOYMENT')
    web_output_dir_infra = pfget(common_pf, 'CACHE_MONTHLY_DEPLOYMENT_INFRA')
    infrasound_mapping = pfget(common_pf, 'INFRASOUND_MAPPING')
    output_dir = '/var/tmp' # FOR TESTING
    sys.path.append(gmtbindir)
    if size == 'wario':
        paper_orientation = 'landscape'
        paper_media = 'b0'
        symsize = '0.3'
    else:
        paper_orientation = 'portrait'
        paper_media = 'a1'
        symsize = '0.15'

    # Make sure execution occurs in the right directory
    cwd = os.getcwd()
    path_parts = cwd.split('/')
    if path_parts[-1] == 'deployment_history' and path_parts[-2] == 'bin':
        if verbose or debug:
            elog.elog_notify(' - Already in the correct current working directory %s' % cwd)
    else:
        cwd = os.getcwd() + '/bin/deployment_history'
        if verbose or debug:
            elog.elog_notify (' - Changed current working directory to %s' % cwd)
        os.chdir(cwd)
    # Make sure we set some GMT parameters for just this script
    # GMTSET
    try:
        set_gmt_params(paper_orientation, paper_media)
    except Exception, e:
        elog.elog_complain("An error occurred setting GMT params %s")
        raise
Esempio n. 2
0
def configure(args):
    try:

        opts, pargs = getopt.getopt(sys.argv[1:], 'dp:P:vV')

    except getopt.GetoptError:

        usage()
        sys.exit(-1)
    
    if( len(pargs) != 1):

        usage()
        sys.exit(-1)

    else:

        globals()['dbname'] = pargs[0]

    for option, value in opts:

        if option in ('-p'):
            globals()['pfname'] = value

    pfname = globals()['pfname'] 

    globals()['port']                       = stock.pfget_int( pfname, "port" )
    globals()['binning_threshold']          = stock.pfget_int( pfname, "binning_threshold" )
    globals()['canvas_size_default']        = stock.pfget_int( pfname, "canvas_size_default" )
    globals()['jquery_dir']                 = stock.pfget_string( pfname, "jquery_dir" )
    globals()['static_dir']                 = stock.pfget_string( pfname, "static_dir" )
    globals()['index_html_template']        = stock.pfget_string( pfname, "index_html_template" )
    globals()['queryparser_html_template']  = stock.pfget_string( pfname, "queryparser_html_template" )
    globals()['waveform_html_template']     = stock.pfget_string( pfname, "waveform_html_template" )
    globals()['application_name']           = stock.pfget_string( pfname, "application_name" )
    globals()['application_title']          = stock.pfget_string( pfname, "application_title" )
    globals()['apply_calib']                = stock.pfget_boolean( pfname, "apply_calib" )
    globals()['display_tracebacks']         = stock.pfget_boolean( pfname, "display_tracebacks" )
    globals()['jquery_files']               = stock.pfget_tbl( pfname, "jquery_files" )
    globals()['default_chans']              = stock.pfget_tbl( pfname, "default_chans" )
    globals()['default_time_window']        = stock.pfget_tbl( pfname, "default_time_window" )
    globals()['filters']                    = stock.pfget_arr( pfname, "filters" )

    for option, value in opts:

        if option in  ('-d'):
            globals()['daemonize'] = True

        if option in  ('-V'):
            globals()['debug'] = True
            globals()['verbose'] = True

        if option in  ('-v'):
            globals()['verbose'] = True

        elif option in ('-P'):
            globals()['port'] = int(value)

    import_paths = stock.pfget_tbl( pfname, "import_paths" )

    for p in import_paths:
        sys.path.insert(0, p)

    argv_remap = list()
    argv_remap.append(sys.argv[0])

    if(not globals()['daemonize']):
        argv_remap.append("-n")

    argv_remap.append("-y")
    argv_remap.append(os.path.join(os.environ['ANTELOPE'], 'data/python/dbwfserver/server.py'))

    return argv_remap