summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-system/msg_daemon.py
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2012-08-15 16:10:16 (GMT)
committerJames Meyer <james.meyer@operamail.com>2012-08-15 16:10:16 (GMT)
commit094bbec4072b32b2d9d81fb94fd262f60611f7e8 (patch)
tree3f8f21dbc101581d8e5055ca1dd687b0b0995fb6 /abs/core/LinHES-system/msg_daemon.py
parent7279cd5152033f4d20b55392559581a8df72b66f (diff)
downloadlinhes_pkgbuild-094bbec4072b32b2d9d81fb94fd262f60611f7e8.zip
linhes_pkgbuild-094bbec4072b32b2d9d81fb94fd262f60611f7e8.tar.gz
linhes_pkgbuild-094bbec4072b32b2d9d81fb94fd262f60611f7e8.tar.bz2
LinHES-system:
-updated for python2 -removed firstboot -added msg_client and msg_daemon -moved displaying help to later in the seq. LinHES-session now uses msg_client
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()