mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-23 17:34:21 +03:00
config: Use memory backend with --test-first-run
Meaning we start with a blank slate of gsettings data, and never save anything to disk.
This commit is contained in:
parent
4b4f532417
commit
61158d3bce
@ -34,10 +34,12 @@ class SettingsWrapper(object):
|
|||||||
"""
|
"""
|
||||||
Wrapper class to simplify interacting with gsettings APIs
|
Wrapper class to simplify interacting with gsettings APIs
|
||||||
"""
|
"""
|
||||||
def __init__(self, settings_id, schemadir):
|
def __init__(self, settings_id, schemadir, test_first_run):
|
||||||
self._root = settings_id
|
self._root = settings_id
|
||||||
|
|
||||||
os.environ["GSETTINGS_SCHEMA_DIR"] = schemadir
|
os.environ["GSETTINGS_SCHEMA_DIR"] = schemadir
|
||||||
|
if test_first_run:
|
||||||
|
os.environ["GSETTINGS_BACKEND"] = "memory"
|
||||||
self._settings = Gio.Settings.new(self._root)
|
self._settings = Gio.Settings.new(self._root)
|
||||||
|
|
||||||
self._settingsmap = {"": self._settings}
|
self._settingsmap = {"": self._settings}
|
||||||
@ -154,7 +156,7 @@ class vmmConfig(object):
|
|||||||
CONSOLE_SCALE_FULLSCREEN = 1
|
CONSOLE_SCALE_FULLSCREEN = 1
|
||||||
CONSOLE_SCALE_ALWAYS = 2
|
CONSOLE_SCALE_ALWAYS = 2
|
||||||
|
|
||||||
def __init__(self, appname, CLIConfig, test_first_run=False):
|
def __init__(self, appname, CLIConfig, test_first_run):
|
||||||
self.appname = appname
|
self.appname = appname
|
||||||
self.appversion = CLIConfig.version
|
self.appversion = CLIConfig.version
|
||||||
self.conf_dir = "/org/virt-manager/%s/" % self.appname
|
self.conf_dir = "/org/virt-manager/%s/" % self.appname
|
||||||
@ -162,7 +164,7 @@ class vmmConfig(object):
|
|||||||
self.test_first_run = bool(test_first_run)
|
self.test_first_run = bool(test_first_run)
|
||||||
|
|
||||||
self.conf = SettingsWrapper("org.virt-manager.virt-manager",
|
self.conf = SettingsWrapper("org.virt-manager.virt-manager",
|
||||||
CLIConfig.gsettings_dir)
|
CLIConfig.gsettings_dir, self.test_first_run)
|
||||||
|
|
||||||
# We don't create it straight away, since we don't want
|
# We don't create it straight away, since we don't want
|
||||||
# to block the app pending user authorization to access
|
# to block the app pending user authorization to access
|
||||||
@ -586,9 +588,6 @@ class vmmConfig(object):
|
|||||||
|
|
||||||
# Manager view connection list
|
# Manager view connection list
|
||||||
def add_conn(self, uri):
|
def add_conn(self, uri):
|
||||||
if self.test_first_run:
|
|
||||||
return
|
|
||||||
|
|
||||||
uris = self.conf.get("/connections/uris")
|
uris = self.conf.get("/connections/uris")
|
||||||
if uris is None:
|
if uris is None:
|
||||||
uris = []
|
uris = []
|
||||||
@ -612,8 +611,6 @@ class vmmConfig(object):
|
|||||||
self.conf.set("/connections/autoconnect", uris)
|
self.conf.set("/connections/autoconnect", uris)
|
||||||
|
|
||||||
def get_conn_uris(self):
|
def get_conn_uris(self):
|
||||||
if self.test_first_run:
|
|
||||||
return []
|
|
||||||
return self.conf.get("/connections/uris")
|
return self.conf.get("/connections/uris")
|
||||||
|
|
||||||
# Manager default window size
|
# Manager default window size
|
||||||
@ -631,9 +628,6 @@ class vmmConfig(object):
|
|||||||
return ((uris is not None) and (uri in uris))
|
return ((uris is not None) and (uri in uris))
|
||||||
|
|
||||||
def set_conn_autoconnect(self, uri, val):
|
def set_conn_autoconnect(self, uri, val):
|
||||||
if self.test_first_run:
|
|
||||||
return
|
|
||||||
|
|
||||||
uris = self.conf.get("/connections/autoconnect")
|
uris = self.conf.get("/connections/autoconnect")
|
||||||
if uris is None:
|
if uris is None:
|
||||||
uris = []
|
uris = []
|
||||||
|
Loading…
Reference in New Issue
Block a user