Ejemplo n.º 1
0
def load_config(args, name_suffix=""):
    """ load configuration file, restoring from backup if necessary cf
    config_args
    """
    config_path, backup_path = get_config_path(args, name_suffix)
    try:
        config = pyon.load_file(config_path)
    except FileNotFoundError:
        logger.warning("Unable to find server configuration file, "
                       "restoring from backup")
        shutil.copyfile(backup_path, config_path)
        config = pyon.load_file(config_path)
    return config
Ejemplo n.º 2
0
    def __init__(self, persist_file, autosave_period=30):
        self.persist_file = persist_file
        self.autosave_period = autosave_period

        try:
            file_data = pyon.load_file(self.persist_file)
        except FileNotFoundError:
            file_data = dict()
        self.data = Notifier({k: (True, v) for k, v in file_data.items()})
Ejemplo n.º 3
0
    def test_persist_format(self):
        data = pyon.load_file(self.persist_file.name)

        for key in [KEY1, KEY2]:
            self.assertTrue(data[key]["persist"])
            self.assertEqual(data[key]["value"], DATA)

        self.assertEqual(data[KEY2]["hdf5_options"]["compression"], COMP)
        self.assertEqual(data[KEY1]["hdf5_options"], dict())
Ejemplo n.º 4
0
    def __init__(self, persist_file, autosave_period=30):
        self.persist_file = persist_file
        self.autosave_period = autosave_period

        try:
            file_data = pyon.load_file(self.persist_file)
        except FileNotFoundError:
            file_data = dict()
        self.data = Notifier({
            k: make_dataset(persist=True,
                            value=v["value"],
                            hdf5_options=v["hdf5_options"])
            for k, v in file_data.items()
        })
Ejemplo n.º 5
0
 def load_ddb_from_disk(self):
     return pyon.load_file(self.persist_file.name)