summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Schlueter <jon.schlueter@gmail.com>2010-05-29 08:43:19 -0400
committerJon Schlueter <jon.schlueter@gmail.com>2010-06-05 09:05:54 -0400
commit0f32f5efe53a8cf4584c6d06af3f4e46cfbba6a4 (patch)
treec2b60c81aabd088d209b9f135cd79797dd35b5d4
parenta5e71ebdccaa40672cf84d5a237a550e5c4f7b89 (diff)
downloadgpsd-0f32f5efe53a8cf4584c6d06af3f4e46cfbba6a4.tar.gz
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
-rw-r--r--gps/fake.py27
-rw-r--r--gpsfake.xml6
-rwxr-xr-xregress-driver7
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 <application>gpspipe</application>,
<application>gpscat</application>, or
<application>gpsmon</application> from the gpsd distribution, or any
other application which is able to create a compatible output.</para>
+
+<para>If <application>gpsfake</application> 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</para>
+
</refsect1>
<refsect1 id='see_also'><title>SEE ALSO</title>
<para>
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.