def __init__(self, options, daemon_url): """ Setup objects: Methods WorkSpaces """ self.config = configfile.get_config(options.config, verbose=False) self.debug = options.debug self.daemon_url = daemon_url # check config file configfile.sanity_check(self.config) self._update_methods() self.target_workdir = self.config['target_workdir'] self.source_workdirs = {self.target_workdir} | self.config.get('source_workdirs', set()) self.workspaces = {} for name, data in self.config['workdir'].items(): if name in self.source_workdirs: path = data[0] slices = data[1] self.workspaces[name] = workspace.WorkSpace(name, path, slices) undefined_workdirs = self.source_workdirs - set(self.workspaces) if undefined_workdirs: print('\nERROR: Workdir(s) missing definition: ' + ', '.join('\"' + x + '\"' for x in undefined_workdirs) + '.') exit(1) check_slices = set(self.workspaces[name].slices for name in self.workspaces) if len(check_slices) > 1: print('\nERROR: Not all workdirs have the same number of slices!') exit(1) put_workspaces({k: v.path for k, v in self.workspaces.items()}) self.DataBase = database.DataBase(self) self.update_database() self.broken = False
def __init__(self, options, daemon_url): """ Setup objects: Methods WorkSpaces """ self.config = configfile.get_config(options.config, verbose=False) self.debug = options.debug self.daemon_url = daemon_url # check config file configfile.sanity_check(self.config) self._update_methods() # initialise workspaces self.workspaces = {} for name, data in self.config['workspace'].items(): path = data[0] slices = data[1] w = workspace.WorkSpace(name, path, slices) if w.ok: # add only if everything whent well in __init__ self.workspaces[name] = w else: # hmm, maybe new target workspace if name == self.config['main_workspace']: self.workspaces[name] = workspace.WorkSpace( name, path, slices, True) put_workspaces({k: v.path for k, v in self.workspaces.items()}) # set current workspace pointers self.set_workspace(self.config['main_workspace']) self.set_remote_workspaces(self.config.get('remote_workspaces', '')) # and update contents self.DataBase = database.DataBase(self) self.update_database() self.broken = False