[tracker/sam/index-file-sync: 11/11] Remove --wait-for argument of tracker-sandbox
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/sam/index-file-sync: 11/11] Remove --wait-for argument of tracker-sandbox
- Date: Mon, 23 Mar 2020 01:49:38 +0000 (UTC)
commit 40ee1bcb6f3c9a034986d021db027cd13698acfb
Author: Sam Thursfield <sam afuera me uk>
Date: Sun Mar 22 20:51:26 2020 +0100
Remove --wait-for argument of tracker-sandbox
This was a workaround for https://gitlab.gnome.org/GNOME/tracker/issues/122
which is no longer needed once
https://gitlab.gnome.org/GNOME/tracker-miners/-/merge_requests/168 is
merged.
README.md | 6 +--
utils/trackertestutils/__main__.py | 96 --------------------------------------
2 files changed, 2 insertions(+), 100 deletions(-)
---
diff --git a/README.md b/README.md
index 64d3ddfc7..1fe7403a2 100644
--- a/README.md
+++ b/README.md
@@ -113,11 +113,9 @@ Now check that it runs the correct version of the Tracker CLI:
./run-uninstalled -- tracker --version
Let's try and index some content. (Subtitute ~/Music for any other location
-where you have interesting data). We need to explicitly tell the script to wait
-for the miners to finish, or it will exit too soon. (This is a workaround for
-[issue #122](https://gitlab.gnome.org/GNOME/tracker/issues/122).)
+where you have interesting data).
- ./run-uninstalled --wait-for-miner=Files --wait-for-miner=Extract -- tracker index --file ~/Music
+ ./run-uninstalled -- tracker index --file ~/Music
Let's see what files were found!
diff --git a/utils/trackertestutils/__main__.py b/utils/trackertestutils/__main__.py
index e7b10e8ed..be4b3773a 100644
--- a/utils/trackertestutils/__main__.py
+++ b/utils/trackertestutils/__main__.py
@@ -24,8 +24,6 @@
#
import argparse
-import collections
-import configparser
import contextlib
import locale
import logging
@@ -36,15 +34,11 @@ import signal
import subprocess
import sys
import tempfile
-import time
-from gi.repository import Gio
from gi.repository import GLib
-from . import dbusdaemon
from . import dconf
from . import helpers
-from . import mainloop
# Script
script_name = 'tracker-sandbox'
@@ -197,12 +191,6 @@ def argument_parser():
parser.add_argument('--index-tmpdir', action='store_true',
help="create index in a temporary directory and "
"delete it on exit (useful for automated testing)")
- parser.add_argument('--wait-for-miner', type=str, action='append',
- help="wait for one or more daemons to start, and "
- "return to idle for at least 1 second, before "
- "exiting. Usually used with `tracker index` where "
- "you should pass --wait-for-miner=Files and "
- "--wait-for-miner=Extract")
parser.add_argument('--debug-dbus', action='store_true',
help="show stdout and stderr messages from every daemon "
"running on the sandbox session bus. By default we "
@@ -253,77 +241,6 @@ def init_logging(debug_sandbox, debug_dbus):
dbus_stdout.addHandler(dbus_handler)
-class MinerStatusWatch():
- """This class provides a way to block waiting for miners to finish.
-
- This is needed because of a deficiency in `tracker index`, see:
- https://gitlab.gnome.org/GNOME/tracker/issues/122
-
- """
- def __init__(self, sandbox, miner_name):
- self.dbus_name = 'org.freedesktop.Tracker1.Miner.' + miner_name
- self.object_path = '/org/freedesktop/Tracker1/Miner/' + miner_name
-
- self._sandbox = sandbox
-
- # Stores a list of (time, status) pairs. This is used to determine
- # if the miner has been idle continuously over a time peroid.
- self._status_log = collections.deque()
-
- def _log_status(self, time, status):
- self._status_log.append((time, status))
- if len(self._status_log) > 100:
- self._status_log.popleft()
-
- def setup(self):
- log.debug(f"Set up status watch on {self.dbus_name}")
- self._proxy = Gio.DBusProxy.new_sync(
- self._sandbox.get_connection(),
- Gio.DBusProxyFlags.NONE, None,
- self.dbus_name, self.object_path, 'org.freedesktop.Tracker1.Miner',
- None)
-
- # FIXME: this doesn't appear to work, so we have to use polling.
- #proxy.connect('g-signal', miner_signal_cb)
-
- # This call will raise GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown
- # if the miner name is invalid.
- status = self._proxy.GetStatus()
- self._log_status(time.time(), status)
- log.debug(f"{self.dbus_name}: Current status: {status}")
-
- def check_was_idle_for_time_period(self, period_seconds):
- now = time.time()
-
- status = self._proxy.GetStatus()
- self._log_status(now, status)
- log.debug(f"{self.dbus_name}: Current status: {status}")
-
- cursor = len(self._status_log) - 1
- previous_delta_from_now = 0
- while True:
- if cursor < 0 or self._status_log[cursor][1] != 'Idle':
- if previous_delta_from_now >= period_seconds:
- return True
- else:
- return False
- previous_delta_from_now = (now - self._status_log[cursor][0])
- cursor -= 1
-
-
-def wait_for_miners(watches):
- # We wait 1 second after "Idle" status is seen before exiting, because the
- # extractor goes to/from Idle frequently.
- wait_for_idle_time = 1
- while True:
- status = [watch.check_was_idle_for_time_period(wait_for_idle_time) for watch in watches.values()]
- if all(status):
- break
- else:
- log.debug(f"Waiting for idle.")
- time.sleep(0.1)
-
-
@contextlib.contextmanager
def ignore_sigint():
handler = signal.signal(signal.SIGINT, signal.SIG_IGN)
@@ -363,10 +280,6 @@ def main():
"from environment and from --verbosity "
"parameter.")
- if args.command is None and args.wait_for_miner is not None:
- raise RuntimeError("--wait-for-miner cannot be used when opening an "
- "interactive shell.")
-
index_location = None
index_tmpdir = None
@@ -387,12 +300,6 @@ def main():
link_to_mime_data()
- miner_watches = {}
- for miner in (args.wait_for_miner or []):
- watch = MinerStatusWatch(sandbox, miner)
- watch.setup()
- miner_watches[miner] = watch
-
try:
if interactive:
if args.dbus_config:
@@ -414,9 +321,6 @@ def main():
except KeyboardInterrupt:
interrupted = True
- if len(miner_watches) > 0:
- wait_for_miners(miner_watches)
-
if interrupted:
log.debug("Process exited due to SIGINT")
sys.exit(0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]