diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2007-12-19 22:28:08 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2007-12-19 22:28:08 +0000 |
commit | 493072ac784c97946a5c42965cf53ecf5d6d2e7a (patch) | |
tree | a4fd93477a1f6d84bd884c0a5640bb96a8b12e07 /gpsfake.py | |
parent | 3b357a9a07fd924aa07645828b005c2fb5e107e9 (diff) | |
download | gpsd-493072ac784c97946a5c42965cf53ecf5d6d2e7a.tar.gz |
Better path handling for gpsfake (patch by bzed).
Diffstat (limited to 'gpsfake.py')
-rw-r--r-- | gpsfake.py | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -312,6 +312,8 @@ class FakeGPS: class DaemonError(exceptions.Exception): def __init__(self, msg): self.msg = msg + def __str__(self): + return repr(self.msg) class DaemonInstance: "Control a gpsd instance." @@ -325,10 +327,21 @@ class DaemonInstance: self.pidfile = "/tmp/gpsfake_pid-%s" % os.getpid() 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 + + if not self.spawncmd: + raise DaemonError("Cannot execute gpsd: executeable not found.") # 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 - self.spawncmd = "gpsd -b -N -S %s -F %s -P %s %s" % (port, self.control_socket, self.pidfile, options) + self.spawncmd += " -b -N -S %s -F %s -P %s %s" % (port, self.control_socket, self.pidfile, options) if prefix: self.spawncmd = prefix + " " + self.spawncmd.strip() if background: |