コード例 #1
0
def SetUp(filename, rel_path=RELATIVE_TEST_PATH):
    """ SetUp returns a parsed C Program."""
    if not os.path.exists(PICKLE_FILE):
        KVStore.CreateNewStore(PICKLE_FILE, redhawk.GetVersion())
    return G.GetLanguageSpecificTree(os.path.join(rel_path, filename),
                                     PICKLE_FILE,
                                     language='c')
コード例 #2
0
    def __init__(self, database_file, parser, store_new=True):
        self.database_file = database_file
        self.parser = parser
        self.store_new = store_new
        # logging.info("Reading..\n")
        if self.database_file is None:
            self.database = None
            return

        if not os.path.exists(database_file):
            logging.warning("Database %s does not exist." %
                            (self.database_file))
            self.database = None
            return

        if not KVStore.IsValidStore(database_file):
            print(database_file)
            logging.error("Not a valid store. Recreating..\n")
            KVStore.RemoveExistingStore(database_file)
            KVStore.CreateNewStore(database_file, redhawk.GetVersion())

        self.database = KVStore.KeyValueStore(database_file,
                                              redhawk.GetVersion())
        # logging.info("Done.")
        return
コード例 #3
0
def TestBadVersionInitKeyValueStore():
    temp_file = GetTempFile()

    KV.CreateNewStore(temp_file, redhawk.GetVersion())
    store = shelve.open(temp_file, 'c')
    store[KV.VERSION_KEY] = '0.0.0'
    store = KV.KeyValueStore(temp_file, redhawk.GetVersion())
    return
コード例 #4
0
def TestCreateAndRemoveStores():
    temp_file = GetTempFile()
    KV.CreateNewStore(temp_file, redhawk.GetVersion())
    store = KV.KeyValueStore(temp_file, redhawk.GetVersion())
    assert (store.GetVersion() == redhawk.GetVersion())
    store.Close()
    KV.RemoveExistingStore(temp_file)
    assert (not os.path.exists(temp_file))
コード例 #5
0
def TestIsValidStore():
    temp_file = GetTempFile()

    KV.CreateNewStore(temp_file, redhawk.GetVersion())
    assert KV.IsValidStore(temp_file)

    fp = open(temp_file, 'w')
    fp.close()
    assert not KV.IsValidStore(temp_file)
コード例 #6
0
    def setUp(self):
        setUp()
        self.temp_file = GetTempFile()
        KV.CreateNewStore(self.temp_file, redhawk.GetVersion())
        store = shelve.open(self.temp_file, 'c')
        store['dog'] = 'woof'
        store['cat'] = 'meow'
        store.close()

        self.store = KV.KeyValueStore(self.temp_file, redhawk.GetVersion())
        return
コード例 #7
0
ファイル: init.py プロジェクト: takluyver/Redhawk
def Main(args):
    parser = optparse.OptionParser(usage, description=description)
    options, args = parser.parse_args(args)

    if len(args):
        parser.error("Extra options given. This command takes no options!")

    if os.path.exists(S.DB_NAME):
        S.ExitWithError("An AST index already exists.")

    KVStore.CreateNewStore(redhawk.GetDBName(), redhawk.GetVersion())
    return
コード例 #8
0
def TestNiceInitKeyValueStore():
    temp_file = GetTempFile()

    KV.CreateNewStore(temp_file, redhawk.GetVersion())
    store = KV.KeyValueStore(temp_file, redhawk.GetVersion())
    return
コード例 #9
0
def TestCreateNewStoreOverExistingStore():
    temp_file = GetTempFile()
    fp = open(temp_file, 'w')
    fp.close()
    KV.CreateNewStore(temp_file, redhawk.GetVersion())