示例#1
0
def load_config(conf_path, name_mod, version=None):
    with open(os.path.join(conf_path, f'.config-{name_mod}.json'), 'r', encoding='utf-8') as conf_file:
        entry = loads(conf_file.read())
        if version and entry.get('%version') != version:
            raise ValueError(f'Unsupported version: got {entry.get("%version", "<none>")} instead of {version}')

        return entry
示例#2
0
    def run(self, id):
        backup = self.datastore.get_by_id('backup', id)
        if not backup:
            raise RpcException(errno.ENOENT, 'Backup {0} not found'.format(id))

        dirlist = self.run_subtask_sync(
            'backup.{0}.list'.format(backup['provider']),
            backup['properties']
        )

        if not any(e['name'] == MANIFEST_FILENAME for e in dirlist):
            raise TaskException(errno.ENOENT, 'No backup found at specified location')

        data = self.download(backup['provider'], backup['properties'], MANIFEST_FILENAME)
        try:
            manifest = loads(data)
        except ValueError:
            raise TaskException(errno.EINVAL, 'Invalid backup manifest')

        return manifest
示例#3
0
    def run(self, id):
        backup = self.datastore.get_by_id('backup', id)
        if not backup:
            raise RpcException(errno.ENOENT, 'Backup {0} not found'.format(id))

        dirlist = self.run_subtask_sync(
            'backup.{0}.list'.format(backup['provider']),
            backup['properties']
        )

        if not any(e['name'] == MANIFEST_FILENAME for e in dirlist):
            raise TaskException(errno.ENOENT, 'No backup found at specified location')

        data = self.download(backup['provider'], backup['properties'], MANIFEST_FILENAME)
        try:
            manifest = loads(data)
        except ValueError:
            raise TaskException(errno.EINVAL, 'Invalid backup manifest')

        return manifest
示例#4
0
def load_config(conf_path, name_mod):
    with open(os.path.join(conf_path, '.config-{0}.json'.format(name_mod)), 'r', encoding='utf-8') as conf_file:
        return loads(conf_file.read())
示例#5
0
def load_config(conf_path, name_mod):
    with open(os.path.join(conf_path, '.config-{0}.json'.format(name_mod)),
              'r',
              encoding='utf-8') as conf_file:
        return loads(conf_file.read())