summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-system/msg_daemon.py
diff options
context:
space:
mode:
Diffstat (limited to 'abs/core/LinHES-system/msg_daemon.py')
-rwxr-xr-xabs/core/LinHES-system/msg_daemon.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/abs/core/LinHES-system/msg_daemon.py b/abs/core/LinHES-system/msg_daemon.py
new file mode 100755
index 0000000..5ca5b09
--- /dev/null
+++ b/abs/core/LinHES-system/msg_daemon.py
@@ -0,0 +1,46 @@
+#!/usr/bin/python2
+#MythVantage osd message deamon.
+#Use the client to send messages to localhost
+import socket
+import sys
+import os
+from subprocess import call
+
+server_address = '/run/msg_socket'
+
+# Make sure the socket does not already exist
+try:
+ os.unlink(server_address)
+except OSError:
+ if os.path.exists(server_address):
+ raise
+# Create a UDS socket
+sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+# Bind the socket to the port
+print >>sys.stderr, 'starting up on %s' % server_address
+sock.bind(server_address)
+#change permissions of socket
+os.chmod(server_address,0777)
+
+# Listen for incoming connections
+sock.listen(1)
+
+while True:
+ # Wait for a connection
+ connection, client_address = sock.accept()
+ try:
+ #print >>sys.stderr, 'connection from', client_address
+ msg=""
+ # Receive the data in small chunks and retransmit it
+ while True:
+ data = connection.recv(16)
+ msg+=data
+ if data:
+ continue
+ else:
+ call(["/usr/LH/bin/lh_message.sh", msg])
+ break
+
+ finally:
+ # Clean up the connection
+ connection.close()