def set_up_environment(self, gsettings, ontodir): """ Sets up the XDG_*_HOME variables and make sure the directories exist gsettings is a list of triplets (schema, key, value) that will be set/unset in gsetting """ assert not gsettings or type(gsettings) is list helpers.log("[Conf] Setting test environment...") for var, directory in TEST_ENV_DIRS.iteritems(): helpers.log("export %s=%s" % (var, directory)) self.__recreate_directory(directory) os.environ[var] = directory for directory in EXTRA_DIRS: self.__recreate_directory(directory) if ontodir: helpers.log("export %s=%s" % ("TRACKER_DB_ONTOLOGIES_DIR", ontodir)) os.environ["TRACKER_DB_ONTOLOGIES_DIR"] = ontodir for var, value in TEST_ENV_VARS.iteritems(): helpers.log("export %s=%s" % (var, value)) os.environ[var] = value # Previous loop should have set DCONF_PROFILE to the test location if gsettings: self.dconf = DConfClient() self.dconf.reset() for (schema, key, value) in gsettings: self.dconf.write(schema, key, value) helpers.log("[Conf] environment ready")
def _apply_settings(self, settings): for schema_name, contents in settings.iteritems(): dconf = DConfClient(schema_name) dconf.reset() for key, value in contents.iteritems(): dconf.write(key, value)