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)
class TrackerSystemAbstraction: 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 unset_up_environment(self): """ Unset the XDG_*_HOME variables from the environment """ for var, directory in TEST_ENV_VARS.iteritems(): if os.environ.has_key(var): del os.environ[var] for var, directory in TEST_ENV_DIRS.iteritems(): if os.environ.has_key(var): del os.environ[var] if (os.environ.has_key("TRACKER_DB_ONTOLOGIES_DIR")): del os.environ["TRACKER_DB_ONTOLOGIES_DIR"] def tracker_store_testing_start(self, confdir=None, ontodir=None): """ Stops any previous instance of the store, calls set_up_environment, and starts a new instances of the store """ self.__stop_tracker_processes() self.set_up_environment(confdir, ontodir) self.store = helpers.StoreHelper() self.store.start() def tracker_store_start(self): self.store.start() def tracker_store_stop_nicely(self): self.store.stop() def tracker_store_stop_brutally(self): self.store.kill() def tracker_store_restart_with_new_ontologies(self, ontodir): self.store.stop() if ontodir: helpers.log("[Conf] Setting %s - %s" % ("TRACKER_DB_ONTOLOGIES_DIR", ontodir)) os.environ["TRACKER_DB_ONTOLOGIES_DIR"] = ontodir try: self.store.start() except dbus.DBusException, e: raise UnableToBootException("Unable to boot the store \n(" + str(e) + ")")
class TrackerSystemAbstraction: 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 unset_up_environment(self): """ Unset the XDG_*_HOME variables from the environment """ for var, directory in TEST_ENV_VARS.iteritems(): if os.environ.has_key(var): del os.environ[var] for var, directory in TEST_ENV_DIRS.iteritems(): if os.environ.has_key(var): del os.environ[var] if os.environ.has_key("TRACKER_DB_ONTOLOGIES_DIR"): del os.environ["TRACKER_DB_ONTOLOGIES_DIR"] def tracker_store_testing_start(self, confdir=None, ontodir=None): """ Stops any previous instance of the store, calls set_up_environment, and starts a new instances of the store """ self.__stop_tracker_processes() self.set_up_environment(confdir, ontodir) self.store = helpers.StoreHelper() self.store.start() def tracker_store_start(self): self.store.start() def tracker_store_stop_nicely(self): self.store.stop() def tracker_store_stop_brutally(self): self.store.kill() def tracker_store_restart_with_new_ontologies(self, ontodir): self.store.stop() if ontodir: helpers.log("[Conf] Setting %s - %s" % ("TRACKER_DB_ONTOLOGIES_DIR", ontodir)) os.environ["TRACKER_DB_ONTOLOGIES_DIR"] = ontodir try: self.store.start() except dbus.DBusException, e: raise UnableToBootException("Unable to boot the store \n(" + str(e) + ")")