From 0f32f5efe53a8cf4584c6d06af3f4e46cfbba6a4 Mon Sep 17 00:00:00 2001 From: Jon Schlueter Date: Sat, 29 May 2010 08:43:19 -0400 Subject: add GPSD_HOME environment variable support to gpsfake check the environment variable GPSD_HOME to find gpsd on path specified if not there check normal PATH env variable for gpsd added note about GPSD_HOME in gpsfake.xml but might not be in correct location changed regress-driver to use GPSD_HOME instead of adding current directory to the PATH --- gps/fake.py | 27 +++++++++++++++++++-------- gpsfake.xml | 6 ++++++ regress-driver | 7 +++---- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/gps/fake.py b/gps/fake.py index d3e4bd0d..a9c37cf3 100644 --- a/gps/fake.py +++ b/gps/fake.py @@ -282,16 +282,27 @@ class DaemonInstance: def spawn(self, options, port, background=False, prefix=""): "Spawn a daemon instance." self.spawncmd = None - if not '/usr/sbin' in os.environ['PATH']: - os.environ['PATH']=os.environ['PATH'] + ":/usr/sbin" - for path in os.environ['PATH'].split(':'): - _spawncmd = "%s/gpsd" % path - if os.path.isfile(_spawncmd) and os.access(_spawncmd, os.X_OK): - self.spawncmd = _spawncmd - break + + # Look for gpsd in GPSD_HOME env variable + if os.environ['GPSD_HOME'] : + for path in os.environ['GPSD_HOME'].split(':'): + _spawncmd = "%s/gpsd" % path + if os.path.isfile(_spawncmd) and os.access(_spawncmd, os.X_OK): + self.spawncmd = _spawncmd + break + + # if we could not find it yet try PATH env variable for it + if not self.spawncmd: + if not '/usr/sbin' in os.environ['PATH']: + os.environ['PATH']=os.environ['PATH'] + ":/usr/sbin" + for path in os.environ['PATH'].split(':'): + _spawncmd = "%s/gpsd" % path + if os.path.isfile(_spawncmd) and os.access(_spawncmd, os.X_OK): + self.spawncmd = _spawncmd + break if not self.spawncmd: - raise DaemonError("Cannot execute gpsd: executable not found.") + raise DaemonError("Cannot execute gpsd: executable not found. Set GPSD_HOME env variable") # The -b option to suppress hanging on probe returns is needed to cope # with OpenBSD (and possibly other non-Linux systems) that don't support # anything we can use to implement the FakeGPS.read() method diff --git a/gpsfake.xml b/gpsfake.xml index cbeb8e95..17b6dd0a 100644 --- a/gpsfake.xml +++ b/gpsfake.xml @@ -160,6 +160,12 @@ be retrieved using gpspipe, gpscat, or gpsmon from the gpsd distribution, or any other application which is able to create a compatible output. + +If gpsfake exits with "Cannot execute +gpsd: executable not found." the environment variable GPSD_HOME can be +set to the path where gpsd can be found. (instead of adding that folder +to the PATH envirnment variable + SEE ALSO diff --git a/regress-driver b/regress-driver index 81c615ef..6cc040cc 100755 --- a/regress-driver +++ b/regress-driver @@ -8,12 +8,11 @@ # Should return an empty blank string if tose are not present. starttime=`date +"%s" 2>/dev/null` -# We need to have the build directory in $PATH to find the new gpsd -# in case there is one in $PATH somewhere else in the system. +# We need to have the build directory in $GPSD_HOME to find the new gpsd if [ "`dirname $0`" = "." ]; then - PATH=`pwd`:${PATH} + GPSD_HOME=`pwd` else - PATH=`dirname $0`:${PATH} + GPSD_HOME=`dirname $0` fi # Arrange to call a gpsfake in the source directory without fuss. -- cgit v1.2.1