diff --git a/board/fischertechnik/TXT/rootfs/var/www/applog.html b/board/fischertechnik/TXT/rootfs/var/www/applog.html new file mode 100644 index 0000000000..b030c1a6b4 --- /dev/null +++ b/board/fischertechnik/TXT/rootfs/var/www/applog.html @@ -0,0 +1,50 @@ + + + + fischertechnik TXT community firmware + + + +

fischertechnik TXT

+ +

Application log

+
+ + diff --git a/board/fischertechnik/TXT/rootfs/var/www/applog.py b/board/fischertechnik/TXT/rootfs/var/www/applog.py index 52532156ea..adc518db05 100644 --- a/board/fischertechnik/TXT/rootfs/var/www/applog.py +++ b/board/fischertechnik/TXT/rootfs/var/www/applog.py @@ -9,40 +9,6 @@ import socket FILE = "/tmp/app.log" -#FILE = "/var/log/syslog" - -def dump_html(): - print('Content-Type: text/html') - print('') - print('') - print('') - print('') - print('fischertechnik TXT community firmware') - print('') - print('') - print('') - print('

fischertechnik TXT

') - - print('

Application console log

') - print('
') - print(' ') - print('') - sys.stdout.flush() - -def htmlize(s): - s = s.replace("&", "&") - s = s.replace("<", "<") - s = s.replace(">", ">") - s = s.replace("\n", "
") - return s def notify_launcher(str): # Create a socket (SOCK_STREAM means a TCP socket) @@ -56,6 +22,13 @@ def notify_launcher(str): finally: sock.close() +def htmlize(s): + s = s.replace("&", "&") + s = s.replace("<", "<") + s = s.replace(">", ">") + s = s.replace("\n", "
") + return s + @asyncio.coroutine def handler(websocket, path): with open(FILE, 'r') as fin: @@ -69,32 +42,27 @@ def handler(websocket, path): asyncio.get_event_loop().stop() - if os.fork(): sys.exit(0) -os.setsid() +time.sleep(1) -if os.fork(): - # request log file creation from launcher - notify_launcher("logging-start") +os.setsid() - # this is the server process which reads the file, monitors - # it for new contents and forwards it to the client - loop = asyncio.get_event_loop() - start_server = websockets.serve(handler, "", 9001) - websocket_server = loop.run_until_complete(start_server) +# request log file creation from launcher +notify_launcher("logging-start") - try: - loop.run_forever() - finally: - websocket_server.close() - loop.run_until_complete(websocket_server.wait_closed()) +# this is the server process which reads the file, monitors +# it for new contents and forwards it to the client +loop = asyncio.get_event_loop() +start_server = websockets.serve(handler, "", 8999) +websocket_server = loop.run_until_complete(start_server) - notify_launcher("logging-stop") - sys.exit(0) +try: + loop.run_forever() +finally: + websocket_server.close() + loop.run_until_complete(websocket_server.wait_closed()) -# some delay to make sure the server is listening -time.sleep(2) -dump_html() +notify_launcher("logging-stop")