示例#1
0
def main():
    global PH5, KEFFILE
    get_args()
    #   Create ph5 file
    EDITMODE = True
    ex = experiment.ExperimentGroup(nickname=PH5)
    ex.ph5open(EDITMODE)
    ex.initgroup()
    #   Update Experiment_t
    if KEFFILE:
        k = kef.Kef(KEFFILE)
        k.open()
        k.read()
        k.batch_update()
        k.close()

    if os.path.exists(RECEIVER_T):
        k = kef.Kef(RECEIVER_T)
        k.open()
        k.read()
        k.batch_update()
        k.close()
    else:
        sys.stderr.write(
            "Warning: /Experiment_g/Receivers_g/Receiver_t not set!\n")
        os.remove("kef.tmp")

    #   Close PH5 file
    ex.ph5close()
    print "Done..."
    os.remove("kef.tmp")
示例#2
0
def update():
    global EX, ARRAY_NAME, KEF
    # There is a bug in batch update that kills kv
    k = kef.Kef(KEF)
    k.open()
    k.read()
    k.rewind()
    ARRAY_NAME = None
    while True:
        p, kv = k.next()
        if not p:
            break
        if 'array_name_a' in kv:
            ARRAY_NAME = kv['array_name_a']
        else:
            LOGGER.error(
                "Kef file does not contain entry for array_name_a. "
                "Can not continue!")
            return False

        ref = EX.ph5_g_reports.ph5_t_report
        if p not in columns.TABLES:
            LOGGER.warning("No table reference for key: {0}. "
                           "Possibly ph5 file is not open or initialized?"
                           .format(p))

        key = []
        errs_keys, errs_required = columns.validate(ref, kv, key)
        for e in errs_keys + errs_required:
            LOGGER.error(e)

        key = None
        columns.populate(ref, kv, key)

    return True
示例#3
0
def populateExperimentTable():
    global EX, KEFFILE
    k = kef.Kef(KEFFILE)
    k.open()
    k.read()
    k.batch_update()
    k.close()
示例#4
0
def set_experiment_t(experiment_t):
    if experiment_t and os.path.exists(experiment_t):
        LOGGER.info("Loading /Experiment_g/Experiment_t using {0}.".format(
            experiment_t))
        k = kef.Kef(experiment_t)
        k.open()
        k.read()
        k.batch_update()
        k.close()
    else:
        LOGGER.warning("Experiment_g/Experiment_t not set! "
                       "Use --kef option to supply a Experiment_t kef file.")
示例#5
0
def set_receiver_t(receiver_t):
    if os.path.exists(receiver_t):
        LOGGER.info(
            "Loading Experiment_g/Receivers_g/Receiver_t using {0}.".format(
                receiver_t))
        k = kef.Kef(receiver_t)
        k.open()
        k.read()
        k.batch_update()
        k.close()
    else:
        LOGGER.warning("{0} file not found.".format(receiver_t))
示例#6
0
def update():
    global EX, ARRAY_NAME, KEF
    #   There is a bug in batch update that kills kv
    k = kef.Kef(KEF)
    k.open()
    k.read()
    #k.batch_update ()
    #k.close () ; sys.exit ()
    k.rewind()
    ARRAY_NAME = None
    while 1:
        p, kv = k.next()
        if not p: break
        if kv.has_key('array_name_a'):
            ARRAY_NAME = kv['array_name_a']
        else:
            sys.stderr.write(
                "Error: Kef file does not contain entry for array_name_a.\nCan not continue!\n"
            )
            return False

        #   XXX   We always append   XXX
        #mo = updateRE.match (p)
        ref = EX.ph5_g_reports.ph5_t_report
        if not columns.TABLES.has_key(p):
            sys.stderr.write("Warning: No table reference for key: %s\n" % p)
            sys.stderr.write("Possibly ph5 file is not open or initialized?\n")

        key = []
        errs_keys, errs_required = columns.validate(ref, kv, key)
        for e in errs_keys + errs_required:
            sys.stderr.write(e + '\n')

        key = None
        columns.populate(ref, kv, key)

    return True