From 70b366ee51a65015e564f1aaefb0d02962082e0a Mon Sep 17 00:00:00 2001 From: "Paul K. Gerke" Date: Wed, 13 Dec 2017 10:14:32 +0000 Subject: [PATCH] Added configurable port & bind addresses --- wine-dispatch/wine-dispatch | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/wine-dispatch/wine-dispatch b/wine-dispatch/wine-dispatch index fd5cf50..4bc79fb 100755 --- a/wine-dispatch/wine-dispatch +++ b/wine-dispatch/wine-dispatch @@ -1,5 +1,7 @@ #!/usr/bin/python3.6 +import os + import sys import struct @@ -18,20 +20,22 @@ class ExecutionHandler(socketserver.BaseRequestHandler): def handle(self): arguments = list(self.read_string() for _ in range(self.read_int())) - + print("CMD", *arguments) print("---------") - + process = subprocess.run(arguments, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - + self.request.sendall(b"e" + struct.pack("B", process.returncode)) self.request.close() - + if __name__ == "__main__": - HOST, PORT = "127.0.0.1", 8889 + HOST = os.environ.get("HOST", "127.0.0.1") + PORT = int(os.environ.get("PORT", "8888")) + print(f"Starting server on {HOST}:{PORT}") # Create the server, binding to localhost on port 9999 with socketserver.ThreadingTCPServer((HOST, PORT), ExecutionHandler) as server: