summaryrefslogtreecommitdiff
path: root/gpsd.hotplug
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2010-12-28 19:39:05 -0500
committerEric S. Raymond <esr@thyrsus.com>2010-12-28 19:39:05 -0500
commitc69b677f3847f664da7500d0582bd51e0b7d7012 (patch)
tree082e774c40882fec4cbe2a842436197cbfc11635 /gpsd.hotplug
parentd8045899c73a37006fcb6672bbb5fc44b6d4484b (diff)
downloadgpsd-c69b677f3847f664da7500d0582bd51e0b7d7012.tar.gz
Polish and better document the udev/hotplug code.
It's working under Ubuntu 10.04.1 LTS.
Diffstat (limited to 'gpsd.hotplug')
-rwxr-xr-xgpsd.hotplug9
1 files changed, 5 insertions, 4 deletions
diff --git a/gpsd.hotplug b/gpsd.hotplug
index afa74f24..805f9419 100755
--- a/gpsd.hotplug
+++ b/gpsd.hotplug
@@ -14,7 +14,7 @@ GPSD_OPTIONS = os.getenv('GPSD_OPTIONS') or ""
WHEREAMI = __file__
-def gpsd_control_connect():
+def gpsd_control_connect(complain=True):
"Acquire a connection to the GPSD control socket."
if not os.path.exists(CONTROL_SOCKET):
syslog.syslog("socket %s doesn't exist" % CONTROL_SOCKET)
@@ -23,7 +23,8 @@ def gpsd_control_connect():
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM, 0)
sock.connect(CONTROL_SOCKET)
except socket.error, msg:
- syslog.syslog("socket %s creation failure: %s" % (CONTROL_SOCKET, msg))
+ if complain:
+ syslog.syslog("socket %s creation failure: %s" % (CONTROL_SOCKET, msg))
if sock:
sock.close()
sock = None
@@ -34,14 +35,14 @@ def gpsd_control_connect():
def gpsd_control(action, argument):
"Pass a command to gpsd; start the daemon if not already running."
syslog.syslog("gpsd_control(action=%s, arg=%s)" % (action, argument))
- connect = gpsd_control_connect()
+ connect = gpsd_control_connect(complain=False)
if connect:
syslog.syslog("reached a running gpsd")
elif action == 'add':
gpsdcmd = "gpsd %s -F %s" % (GPSD_OPTIONS, CONTROL_SOCKET)
syslog.syslog("launching %s" % gpsdcmd)
os.system(gpsdcmd)
- connect = gpsd_control_connect()
+ connect = gpsd_control_connect(complain=True)
if not connect:
syslog.syslog("can't reach gpsd")
return None