[tracker/sam/sandbox-improvements: 1/4] trackertestutils: Use DConf instead of config files
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/sam/sandbox-improvements: 1/4] trackertestutils: Use DConf instead of config files
- Date: Sun, 8 Mar 2020 23:47:38 +0000 (UTC)
commit 6907e7c8f93cb78a7c4be9dc94ac3efc42771d04
Author: Sam Thursfield <sam afuera me uk>
Date: Sun Mar 8 18:38:49 2020 +0100
trackertestutils: Use DConf instead of config files
The DConf settings will be stored inside the sandbox directory inside
the `config/dconf` subdirectory.
utils/trackertestutils/__main__.py | 74 ++++++--------------------------------
1 file changed, 10 insertions(+), 64 deletions(-)
---
diff --git a/utils/trackertestutils/__main__.py b/utils/trackertestutils/__main__.py
index 9828e102f..7a6b09e7d 100644
--- a/utils/trackertestutils/__main__.py
+++ b/utils/trackertestutils/__main__.py
@@ -42,6 +42,7 @@ from gi.repository import Gio
from gi.repository import GLib
from . import dbusdaemon
+from . import dconf
from . import helpers
from . import mainloop
@@ -56,36 +57,6 @@ store_proc = None
original_xdg_data_home = GLib.get_user_data_dir()
-# Template config file
-config_template = """
-[General]
-verbosity=0
-sched-idle=0
-initial-sleep=0
-
-[Monitors]
-enable-monitors=false
-
-[Indexing]
-throttle=0
-index-on-battery=true
-index-on-battery-first-time=true
-index-removable-media=false
-index-optical-discs=false
-low-disk-space-limit=-1
-index-recursive-directories=;
-index-single-directories=;
-ignored-directories=;
-ignored-directories-with-content=;
-ignored-files=
-crawling-interval=-1
-removable-days-threshold=3
-
-[Writeback]
-enable-writeback=false
-"""
-
-
log = logging.getLogger('sandbox')
@@ -134,8 +105,6 @@ def create_sandbox(index_location, prefix=None, verbosity=0, dbus_config=None,
environment_set_and_add_path(extra_env, 'XDG_DATA_DIRS', prefix, 'share')
# Preferences
- extra_env['TRACKER_USE_CONFIG_FILES'] = 'yes'
-
extra_env['G_MESSAGES_PREFIXED'] = 'all'
extra_env['TRACKER_VERBOSITY'] = str(verbosity)
@@ -155,27 +124,8 @@ def create_sandbox(index_location, prefix=None, verbosity=0, dbus_config=None,
return sandbox
-def config_set(content_locations_recursive=None, content_locations_single=None):
- # Make sure File System miner is configured correctly
- config_dir = os.path.join(os.environ['XDG_CONFIG_HOME'], 'tracker')
- config_filename = os.path.join(config_dir, 'tracker-miner-fs.cfg')
-
- log.debug('Using config file "%s"' % config_filename)
-
- # Only update config if we're updating the database
- os.makedirs(config_dir, exist_ok=True)
-
- if not os.path.exists(config_filename):
- f = open(config_filename, 'w')
- f.write(config_template)
- f.close()
-
- log.debug(' Miner config file written')
-
- # Set content path
- config = configparser.ConfigParser()
- config.optionxform = str
- config.read(config_filename)
+def config_set(sandbox, content_locations_recursive=None, content_locations_single=None):
+ dconfclient = dconf.DConfClient(sandbox)
if content_locations_recursive:
log.debug("Using content locations: %s" %
@@ -189,16 +139,12 @@ def config_set(content_locations_recursive=None, content_locations_single=None):
for dir in locations]
return GLib.Variant('as', locations).print_(False)
- if not config.has_section('General'):
- config.add_section('General')
-
- config.set('General', 'index-recursive-directories',
- locations_gsetting(content_locations_recursive or []))
- config.set('General', 'index-single-directories',
- locations_gsetting(content_locations_single or []))
-
- with open(config_filename, 'w') as f:
- config.write(f)
+ dconfclient.write('org.freedesktop.Tracker.Miner.Files',
+ 'index-recursive-directories',
+ locations_gsetting(content_locations_recursive or []))
+ dconfclient.write('org.freedesktop.Tracker.Miner.Files',
+ 'index-single-directories',
+ locations_gsetting(content_locations_recursive or []))
def link_to_mime_data():
@@ -432,7 +378,7 @@ def main():
sandbox = create_sandbox(index_location, args.prefix, verbosity,
dbus_config=args.dbus_config,
interactive=interactive)
- config_set()
+ config_set(sandbox)
link_to_mime_data()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]