From 34d08d925516a8373baf6b8b01d31da99cc94e17 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 25 Jan 2018 19:02:15 -0500 Subject: [PATCH] terminal.py http additions --- op25/gr-op25_repeater/apps/terminal.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/op25/gr-op25_repeater/apps/terminal.py b/op25/gr-op25_repeater/apps/terminal.py index 82579e8..d562880 100755 --- a/op25/gr-op25_repeater/apps/terminal.py +++ b/op25/gr-op25_repeater/apps/terminal.py @@ -207,6 +207,26 @@ class curses_terminal(threading.Thread): self.keep_running = False self.send_command('quit', 0) +class http_terminal(threading.Thread): + def __init__(self, input_q, output_q, endpoint, **kwds): + from http import http_server + + threading.Thread.__init__ (self, **kwds) + self.setDaemon(1) + self.input_q = input_q + self.output_q = output_q + self.endpoint = endpoint + self.keep_running = True + self.server = http_server(self.input_q, self.output_q, self.endpoint) + + self.start() + + def end_terminal(self): + self.keep_running = False + + def run(self): + self.server.run() + class udp_terminal(threading.Thread): def __init__(self, input_q, output_q, port, **kwds): threading.Thread.__init__ (self, **kwds) @@ -256,6 +276,8 @@ def op25_terminal(input_q, output_q, terminal_type): elif terminal_type[0].isdigit(): port = int(terminal_type) return udp_terminal(input_q, output_q, port) + elif terminal_type.startswith('http:'): + return http_terminal(input_q, output_q, terminal_type.replace('http:', '')) else: sys.stderr.write('warning: unsupported terminal type: %s\n', terminal_type) return None