コード例 #1
0
ファイル: test_safecommands.py プロジェクト: raw-db/ldb-wn
def test_raise():
    "test if it raises exception correctly when trying to run a command"
    f = str(uuid.uuid4())
    # just to be sure this file does not exist
    while os.path.isfile(f):
        f = str(uuid.uuid4())

    cmd = 'ls %s' % f
    try:
        getstatusoutput(cmd, throw=True)
    except CommandException :
        return

    # should have thrown a CommandException
    assert(False)
コード例 #2
0
ファイル: metadata.py プロジェクト: raw-db/ldb-wn
def format(ldbconfig):
    logging.info("Formatting the %s Shore database..." % ldbconfig)
    s, o = safecommands.getstatusoutput("LDBCONFIG=\"%s\" %s format" % (ldbconfig, ODL_BIN))
    if s != 0:
        logging.error("Failed with error: %s" % o.strip())
        raise MetadataException("Failed during format")
    logging.info("...done")
コード例 #3
0
ファイル: metadata.py プロジェクト: raw-db/ldb-wn
def list_schemas(user, module):
    ldbconfig = user_storage.ldbconfig(user)
    s, o = safecommands.getstatusoutput("LDBCONFIG=\"%s\" %s list_extents %s" % (ldbconfig, ODL_BIN, module))
    if s != 0:
        logging.error("Failed with error: %s" % o.strip())
        raise MetadataException("Failed during list_schemas")
    schemas = []
    for l in o.strip().splitlines():
        schemas.append(l[len(module)+2:])   # Skip 'Module::'
    print schemas
    return schemas
コード例 #4
0
ファイル: metadata.py プロジェクト: raw-db/ldb-wn
def register_shore_schema(user, module, name, schema):
    ldbconfig = user_storage.ldbconfig(user)
    raw_types_to_odl = RawTypesToOdl(name, schema)
    odl = raw_types_to_odl.to_odl()

    f = tempfile.NamedTemporaryFile(delete=False, suffix='.odl')
    f.write("module %s {" % module)
    f.write(odl)
    f.write("};")
    f.close()

    logging.info("Create schema and data entries in %s Shore from ODL file %s ..." % (user, f.name))
    s, o = safecommands.getstatusoutput("LDBCONFIG=\"%s\" %s shore_append %s" % (ldbconfig, ODL_BIN, f.name))
    if s != 0:
        raise MetadataException("Failed during shore_insert of ODL file %s" % f.name)
    logging.info("...done")