diff --git a/src/filters/rclexecm.py b/src/filters/rclexecm.py index 27e68048..15591155 100644 --- a/src/filters/rclexecm.py +++ b/src/filters/rclexecm.py @@ -24,6 +24,9 @@ import os import tempfile import shutil import getopt +import rclconfig + +my_config = rclconfig.RclConfig() ############################################ # RclExecM implements the @@ -207,6 +210,10 @@ def which(program): def path_candidates(): yield os.path.dirname(sys.argv[0]) + rclpath = my_config.getConfParam("recollhelperpath") + if rclpath: + for path in rclpath.split(os.pathsep): + yield path for path in os.environ["PATH"].split(os.pathsep): yield path diff --git a/src/python/recoll/recoll/rclconfig.py b/src/python/recoll/recoll/rclconfig.py index 12485fa9..28cb4e5a 100755 --- a/src/python/recoll/recoll/rclconfig.py +++ b/src/python/recoll/recoll/rclconfig.py @@ -1,10 +1,12 @@ #!/usr/bin/env python +from __future__ import print_function import locale import re import os import sys import base64 +import platform class ConfSimple: """A ConfSimple class reads a recoll configuration file, which is a typical @@ -143,14 +145,23 @@ class RclDynConf: class RclConfig: def __init__(self, argcnf = None): + platsys = platform.system() # Find configuration directory if argcnf is not None: self.confdir = os.path.abspath(argcnf) elif "RECOLL_CONFDIR" in os.environ: self.confdir = os.environ["RECOLL_CONFDIR"] else: - self.confdir = os.path.expanduser("~/.recoll") - #print("Confdir: [%s]" % self.confdir) + if platsys == "Windows": + if "LOCALAPPDATA" in os.environ: + dir = os.environ["LOCALAPPDATA"] + else: + dir = os.path.expanduser("~") + self.confdir = os.path.join(dir, "Recoll") + else: + self.confdir = os.path.expanduser("~/.recoll") + #print("Confdir: [%s]" % self.confdir, file=sys.stderr) + # Also find datadir. This is trickier because this is set by # "configure" in the C code. We can only do our best. Have to # choose a preference order. Use RECOLL_DATADIR if the order is wrong @@ -158,14 +169,17 @@ class RclConfig: if "RECOLL_DATADIR" in os.environ: self.datadir = os.environ["RECOLL_DATADIR"] else: - dirs = ("/opt/local", "/usr", "/usr/local") - for dir in dirs: - dd = os.path.join(dir, "share/recoll") - if os.path.exists(dd): - self.datadir = dd + if platsys == "Windows": + self.datadir = os.path.join(os.path.dirname(sys.argv[0]), "..") + else: + dirs = ("/opt/local", "/usr", "/usr/local") + for dir in dirs: + dd = os.path.join(dir, "share/recoll") + if os.path.exists(dd): + self.datadir = dd if self.datadir is None: self.datadir = "/usr/share/recoll" - #print("Datadir: [%s]" % self.datadir) + #print("Datadir: [%s]" % self.datadir, file=sys.stderr) self.cdirs = [] # Additional config directory, values override user ones @@ -176,7 +190,7 @@ class RclConfig: if "RECOLL_CONFMID" in os.environ: self.cdirs.append(os.environ["RECOLL_CONFMID"]) self.cdirs.append(os.path.join(self.datadir, "examples")) - + #print("Config dirs: %s" % self.cdirs, file=sys.stderr) self.config = ConfStack("recoll.conf", self.cdirs, "tree") self.keydir = '' diff --git a/src/sampleconf/recoll.conf b/src/sampleconf/recoll.conf index 7087e1db..23c40cbd 100644 --- a/src/sampleconf/recoll.conf +++ b/src/sampleconf/recoll.conf @@ -202,6 +202,10 @@ idxflushmb = 10 # the environment, we use it instead. Defaults to $prefix/share/recoll/filters # filtersdir = /path/to/my/filters +# Additional places to search for helper executables. This is only used on +# Windows for now +# recollhelperpath = c:/someprog/bin;c:/someotherprog/bin + # Place to search for icons. The only reason to change this would be if you # want to change the icons displayed in the result list. # Defaults to $prefix/share/recoll/images diff --git a/src/windows/mkinstdir.sh b/src/windows/mkinstdir.sh index 34d41607..45abaf0c 100644 --- a/src/windows/mkinstdir.sh +++ b/src/windows/mkinstdir.sh @@ -53,6 +53,7 @@ copyrecoll() cc $RECOLL/sampleconf/recoll.qss $DESTDIR/Share/examples cp $RECOLL/filters/* $FILTERS || exit 1 + cp $RECOLL/python/recoll/recoll/rclconfig.py $FILTERS || exit 1 } copyantiword()