Exemple #1
0
    if os.path.exists(f_lock):
        return True

    return False


if __name__ == '__main__':
    if len(sys.argv) == 1:
        sys.argv.append("--help")

    (isCONDA, QA_SRC) = qa_util.get_QA_SRC(sys.argv[0])

    qa_init.run_install(QA_SRC)  # exit after processing, if any

    # for options on the command-line as well as in configuration files
    qaConf = QaConfig(QA_SRC)

    g_vars = GlobalVariables()
    t_vars = ThreadVariables()

    g_vars.qa_src = QA_SRC
    g_vars.isConda = isCONDA
    g_vars.pid = str(os.getpid())
    g_vars.UDUNITS2_XML_PATH = qaConf.getOpt("UDUNITS2_XML_PATH")

    if 'QA_EXAMPLE' in qaConf.dOpts:
        qaConf = prepareExample(qaConf)

    if isCONDA:
        qaConf.addOpt('CONDA', True)
Exemple #2
0
def prepareExample(qaConf):
    if not qaConf.isOpt('PROJECT'):
        qaConf.addOpt("PROJECT", 'CORDEX')

    if qaConf.isOpt('WORK'):
        currdir = qaConf.getOpt('WORK')
    else:
        currdir = qaConf.getOpt('CURR_DIR')

    #currdir=os.path.join(currdir, 'example')
    qaConf.dOpts['QA_RESULTS'] = os.path.join(currdir, 'results')

    if not qa_util.mkdirP(currdir):
        sys.exit(1)

    os.chdir(currdir)
    qa_util.rm_r('results', 'config.txt', 'qa-test.task')

    print 'make examples in ' + currdir
    print 'make qa_test.task'

    taskFile = os.path.join(QA_SRC, 'example', 'templates', 'qa-test.task')
    shutil.copy(taskFile, currdir)
    taskFile = 'qa-test.task'

    # replace templates within QA_SRC/example
    sub = []
    repl = []

    sub.append('PROJECT_DATA=data')
    repl.append('PROJECT_DATA=' + os.path.join(currdir, 'data'))

    sub.append('QA_RESULTS=results')
    repl.append('QA_RESULTS=' + os.path.join(currdir, 'results'))

    qa_util.f_str_replace(taskFile, sub, repl)

    if not qa_util.which("ncgen"):
        print "building data in example requires the ncgen utility"
        sys.exit(1)

    if not os.path.isdir(os.path.join(currdir, 'data')):
        # data
        print 'make data'
        p = os.path.join(QA_SRC, 'example', 'templates', 'data.tbz')
        subprocess.call(["tar", "--bzip2", "-xf", p])

        for rs, ds, fs in os.walk('data'):
            for f in fs:
                nc_f = f[:len(f) - 3] + 'nc'
                t_f = os.path.join(rs, f)
                t_nc = os.path.join(rs, nc_f)
                try:
                    subprocess.call(["ncgen", "-k", "3", "-o", t_nc, t_f])
                except:
                    print 'making of example failed'
                    sys.exit(1)
                else:
                    qa_util.rm_r(t_f)

    print 'run' + sys.argv[0] + " -m -f " + currdir + "/qa-test.task"

    qaConf = QaConfig(QA_SRC, ['-m', '-f', currdir + "/qa-test.task"])

    return qaConf
Exemple #3
0
        f_lock = os.path.join(t_vars.var_path, 'qa_lock_' + fBase + '.txt')

        if os.path.exists(f_lock):
            retVal = True

    return retVal


if __name__ == '__main__':
    if len(sys.argv) == 1:
        sys.argv.append("--help")

    (isCONDA, QA_SRC) = qa_util.get_QA_SRC(sys.argv[0])

    # for options on the command-line as well as in configuration files
    qaConf = QaConfig(QA_SRC, isCONDA)

    g_vars = GlobalVariables()
    t_vars = ThreadVariables()

    g_vars.qa_src = QA_SRC
    g_vars.isConda = isCONDA
    g_vars.pid = str(os.getpid())
    g_vars.UDUNITS2_XML_PATH = qaConf.getOpt("UDUNITS2_XML_PATH")

    if 'QA_EXAMPLE' in qaConf.dOpts:
        qaConf = prepareExample(qaConf)

    log = Log(qaConf.dOpts)

    # obj for getting and iteration next path