From 0327c8e0e5adbaa3c334a7c4e694ff4fc186ab6e Mon Sep 17 00:00:00 2001 From: Akashdeep Dhar Date: Mar 05 2021 05:46:56 +0000 Subject: Graduated termsocket prompts from print to echo Signed-off-by: Akashdeep Dhar --- diff --git a/dish/term.py b/dish/term.py index c7d8d41..77f87c8 100644 --- a/dish/term.py +++ b/dish/term.py @@ -24,6 +24,7 @@ import tornado.web from terminado import TermSocket, UniqueTermManager import sys from hashlib import sha256 +from click import echo class AttachmentEndpoint(tornado.web.RequestHandler): @@ -36,7 +37,7 @@ class AttachmentEndpoint(tornado.web.RequestHandler): comdexec = self.get_argument("comdexec") self.write(addhandr(contiden, comdexec)) except Exception as expt: - print("Console attachment failed! - " + str(expt)) + echo(" * Console attachment failed! - " + str(expt)) self.set_header("Access-Control-Allow-Origin", "*") self.write({"retnmesg": "deny"}) @@ -61,18 +62,18 @@ def mainterm(portqant): try: global mainobjc mainobjc = tornado.web.Application(handlers) - print(" * TermSocket started on port " + portqant) + echo(" * TermSocket started on port " + portqant) mainobjc.listen(portqant, "0.0.0.0") IOLoop.instance().start() except KeyboardInterrupt: - print("\nShutting down on SIGINT") + echo("\n" + " * Shutting down on SIGINT") finally: sys.exit() def addhandr(contiden, comdexec): try: - print(" * " + comdexec + " attached to " + contiden) + echo(" * " + comdexec + " attached to " + contiden) urlpatrn = sha256((contiden + comdexec).encode()).hexdigest() comdexec = comdexec.split() stndexec = ["docker", "exec", "-ti", contiden] @@ -94,7 +95,7 @@ def addhandr(contiden, comdexec): "urlpatrn": urlpatrn } except Exception as expt: - print(" * Failed to attach terminal" + "\n" + str(expt)) + echo(" * Failed to attach terminal" + "\n" + str(expt)) return { "retnmesg": "deny" }