From f75693d1194d0ea4a546a1857c95d5e82de398f0 Mon Sep 17 00:00:00 2001 From: Robert Schneider Date: Tue, 6 Aug 2019 11:37:17 -0700 Subject: [PATCH 1/5] Issue #110 - Made GUI port optionally configurable Instead of defaulting to port 8080, the ait gui should now look at the ait config and pull the defined gui.port number from there if its defined. If it is not defined, then it will use the default of 8080. All of which gets overwritten if the user provided a port number to the init method --- ait/gui/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ait/gui/__init__.py b/ait/gui/__init__.py index 803efbc6..149f1c69 100644 --- a/ait/gui/__init__.py +++ b/ait/gui/__init__.py @@ -216,7 +216,7 @@ def process_log_msg(self, msg): def getBrowserName(self, browser): return getattr(browser, 'name', getattr(browser, '_name', '(none)')) - def init(self, host=None, port=8080): + def init(self, host=None, port=ait.config.get('gui.port', 8080)): # The /cmd endpoint requires access to the AITGUIPlugin object so it # can publish commands via the Plugin interface. It's defined here with From 39d0e4bd6b81ff678813ce2ba4e2758ff7b5e9b5 Mon Sep 17 00:00:00 2001 From: Robert Schneider Date: Tue, 13 Aug 2019 12:36:21 -0700 Subject: [PATCH 2/5] Issue #110 - Moved gui port kwarg to plugin init Action requested from the PR review. Moved the port argument to the plugin class init as a kwarg with a default to port 8080. Kwarg gets populated based on whats defined in config.yaml. --- ait/gui/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ait/gui/__init__.py b/ait/gui/__init__.py index 149f1c69..41a48632 100644 --- a/ait/gui/__init__.py +++ b/ait/gui/__init__.py @@ -171,7 +171,11 @@ def __init__(self, inputs, outputs, zmq_args=None, **kwargs): bottle.TEMPLATE_PATH.append(HTMLRoot.User) - gevent.spawn(self.init) + port = 8080 + if 'port' in kwargs: + port = int(kwargs['port']) + + gevent.spawn(self.init, port=port) def process(self, input_data, topic=None): # msg is going to be a tuple from the ait_packet_handler @@ -216,7 +220,7 @@ def process_log_msg(self, msg): def getBrowserName(self, browser): return getattr(browser, 'name', getattr(browser, '_name', '(none)')) - def init(self, host=None, port=ait.config.get('gui.port', 8080)): + def init(self, host=None, port=8080): # The /cmd endpoint requires access to the AITGUIPlugin object so it # can publish commands via the Plugin interface. It's defined here with From d7c57f2860e03372e9f351ae6c92b3823f776899 Mon Sep 17 00:00:00 2001 From: Robert Schneider Date: Tue, 13 Aug 2019 14:49:09 -0700 Subject: [PATCH 3/5] Issue #110 - Changed AIT gui kwargs to attributes Instead of passing in the values to the GUIs self.init method, the init method will see if the plugin has the port and host items defined as attributes. --- ait/gui/__init__.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ait/gui/__init__.py b/ait/gui/__init__.py index 41a48632..7aa5fce6 100644 --- a/ait/gui/__init__.py +++ b/ait/gui/__init__.py @@ -171,11 +171,7 @@ def __init__(self, inputs, outputs, zmq_args=None, **kwargs): bottle.TEMPLATE_PATH.append(HTMLRoot.User) - port = 8080 - if 'port' in kwargs: - port = int(kwargs['port']) - - gevent.spawn(self.init, port=port) + gevent.spawn(self.init) def process(self, input_data, topic=None): # msg is going to be a tuple from the ait_packet_handler @@ -220,7 +216,7 @@ def process_log_msg(self, msg): def getBrowserName(self, browser): return getattr(browser, 'name', getattr(browser, '_name', '(none)')) - def init(self, host=None, port=8080): + def init(self): # The /cmd endpoint requires access to the AITGUIPlugin object so it # can publish commands via the Plugin interface. It's defined here with @@ -259,7 +255,14 @@ def handle(pathname): def handle(pathname): return bottle.static_file(pathname, root=HTMLRoot.User) - if host is None: + if hasattr(self, 'port'): + port = int(self.port) + else: + port = 8080 + + if hasattr(self, 'host'): + host = self.host + else: host = 'localhost' streams = ait.config.get('gui.telemetry') From 0d61967f43f5dae8063f242825873496d44c4cff Mon Sep 17 00:00:00 2001 From: Robert Schneider Date: Tue, 20 Aug 2019 13:17:46 -0700 Subject: [PATCH 4/5] Issue #110 - Use getadder for GUI init port & host --- ait/gui/__init__.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/ait/gui/__init__.py b/ait/gui/__init__.py index 7aa5fce6..9c6f884e 100644 --- a/ait/gui/__init__.py +++ b/ait/gui/__init__.py @@ -255,15 +255,8 @@ def handle(pathname): def handle(pathname): return bottle.static_file(pathname, root=HTMLRoot.User) - if hasattr(self, 'port'): - port = int(self.port) - else: - port = 8080 - - if hasattr(self, 'host'): - host = self.host - else: - host = 'localhost' + port = int(getattr(self, 'port', 8080)): + host = getattr(self, 'port', 'localhost'): streams = ait.config.get('gui.telemetry') From a96cb98d7981423673a383bdd7e180145b7d8907 Mon Sep 17 00:00:00 2001 From: Robert Schneider Date: Fri, 23 Aug 2019 09:04:25 -0700 Subject: [PATCH 5/5] Issue #110 - Fixed typo in host and port --- ait/gui/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ait/gui/__init__.py b/ait/gui/__init__.py index 9c6f884e..567af211 100644 --- a/ait/gui/__init__.py +++ b/ait/gui/__init__.py @@ -256,7 +256,7 @@ def handle(pathname): return bottle.static_file(pathname, root=HTMLRoot.User) port = int(getattr(self, 'port', 8080)): - host = getattr(self, 'port', 'localhost'): + host = getattr(self, 'host', 'localhost'): streams = ait.config.get('gui.telemetry')