From 3e63f04ff43d87c5ddd53c9a184e67ebcfe61486 Mon Sep 17 00:00:00 2001 From: Kayo Kallas Date: Mon, 21 Sep 2020 11:56:02 -0700 Subject: [PATCH 1/7] Issue #138 - pull static file location from config.yaml --- ait/gui/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ait/gui/__init__.py b/ait/gui/__init__.py index 07679f70..3560d883 100644 --- a/ait/gui/__init__.py +++ b/ait/gui/__init__.py @@ -241,7 +241,12 @@ def reset(self): class HTMLRoot: Static = pkg_resources.resource_filename('ait.gui', 'static/') - User = ait.config.get('gui.html.directory', Static) + User = None + plugins = ait.config.get('server.plugins', Static) + for plugin in plugins: + if plugin['plugin']['name'] == 'ait.gui.AITGUIPlugin': + User = plugin['plugin']['html']['directory'] + break SEQRoot = ait.config.get('sequence.directory', None) if SEQRoot and not os.path.isdir(SEQRoot): From a949935d6bff428d90afc9bb614f0fd2204ca2f3 Mon Sep 17 00:00:00 2001 From: Kayo Kallas Date: Tue, 6 Oct 2020 06:53:53 -0700 Subject: [PATCH 2/7] Issue #138 - make AITGUIPlugin to call HTMLRoot --- ait/gui/__init__.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/ait/gui/__init__.py b/ait/gui/__init__.py index 3560d883..615dd8f3 100644 --- a/ait/gui/__init__.py +++ b/ait/gui/__init__.py @@ -239,15 +239,25 @@ def reset(self): _RUNNING_SEQ = None CMD_API = ait.core.api.CmdAPI() + class HTMLRoot: Static = pkg_resources.resource_filename('ait.gui', 'static/') User = None plugins = ait.config.get('server.plugins', Static) for plugin in plugins: if plugin['plugin']['name'] == 'ait.gui.AITGUIPlugin': - User = plugin['plugin']['html']['directory'] + User = plugin['plugin'] break + try: + with open(os.path.join(Static, 'package.json')) as infile: + package_data = json.loads(infile.read()) + VERSION = 'AIT GUI v{}'.format(package_data['version']) + log.info('Running {}'.format(VERSION)) + except: + VERSION = '' + log.warn('Unable to determine which AIT GUI Version is running') + SEQRoot = ait.config.get('sequence.directory', None) if SEQRoot and not os.path.isdir(SEQRoot): msg = 'sequence.directory does not exist. Sequence loads may fail.' @@ -266,17 +276,6 @@ class HTMLRoot: Greenlets = [] -try: - with open(os.path.join(HTMLRoot.Static, 'package.json')) as infile: - package_data = json.loads(infile.read()) - VERSION = 'AIT GUI v{}'.format(package_data['version']) - log.info('Running {}'.format(VERSION)) -except: - VERSION = '' - log.warn('Unable to determine which AIT GUI Version is running') - - - class AITGUIPlugin(Plugin): global playback From 54d8fa9a74af41e368f76c495cad606852b6c805 Mon Sep 17 00:00:00 2001 From: Kayo Kallas Date: Mon, 2 Nov 2020 19:32:30 -0800 Subject: [PATCH 3/7] Issue #138 - set HTMLRoot.User to Static --- ait/gui/__init__.py | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/ait/gui/__init__.py b/ait/gui/__init__.py index 615dd8f3..1de1b2e8 100644 --- a/ait/gui/__init__.py +++ b/ait/gui/__init__.py @@ -241,22 +241,7 @@ def reset(self): class HTMLRoot: - Static = pkg_resources.resource_filename('ait.gui', 'static/') - User = None - plugins = ait.config.get('server.plugins', Static) - for plugin in plugins: - if plugin['plugin']['name'] == 'ait.gui.AITGUIPlugin': - User = plugin['plugin'] - break - - try: - with open(os.path.join(Static, 'package.json')) as infile: - package_data = json.loads(infile.read()) - VERSION = 'AIT GUI v{}'.format(package_data['version']) - log.info('Running {}'.format(VERSION)) - except: - VERSION = '' - log.warn('Unable to determine which AIT GUI Version is running') + Static = User = pkg_resources.resource_filename('ait.gui', 'static/') SEQRoot = ait.config.get('sequence.directory', None) if SEQRoot and not os.path.isdir(SEQRoot): @@ -276,6 +261,17 @@ class HTMLRoot: Greenlets = [] +try: + with open(os.path.join(Static, 'package.json')) as infile: + package_data = json.loads(infile.read()) + VERSION = 'AIT GUI v{}'.format(package_data['version']) + log.info('Running {}'.format(VERSION)) +except: + VERSION = '' + log.warn('Unable to determine which AIT GUI Version is running') + + + class AITGUIPlugin(Plugin): global playback From 476c62ed281a5e946f8b0e848de5bbe793bbcc24 Mon Sep 17 00:00:00 2001 From: Kayo Kallas Date: Mon, 2 Nov 2020 19:41:41 -0800 Subject: [PATCH 4/7] Issue #138 - change Static to HTMLRoot.Static --- 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 1de1b2e8..032a5b28 100644 --- a/ait/gui/__init__.py +++ b/ait/gui/__init__.py @@ -262,7 +262,7 @@ class HTMLRoot: try: - with open(os.path.join(Static, 'package.json')) as infile: + with open(os.path.join(HTMLRoot.Static, 'package.json')) as infile: package_data = json.loads(infile.read()) VERSION = 'AIT GUI v{}'.format(package_data['version']) log.info('Running {}'.format(VERSION)) From 66dfe5953e5bb4b19834bcf6388eae82a81b5cd9 Mon Sep 17 00:00:00 2001 From: Kayo Kallas Date: Mon, 2 Nov 2020 19:43:35 -0800 Subject: [PATCH 5/7] Issue #138 - add static directory config setup example --- doc/source/new_project.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/source/new_project.rst b/doc/source/new_project.rst index 1b4e76fb..f8fbeb34 100644 --- a/doc/source/new_project.rst +++ b/doc/source/new_project.rst @@ -80,6 +80,8 @@ You'll need to update your **server** configuration to enable the GUI Plugin. Ad - telem_stream outputs: - command_stream + html: + directory: /path/to/ait-gui/static/dir The definitions for **log_stream**, **telem_stream**, and **command_stream** exist in the example Core **config.yaml** file. From 28bc4e6662e9adb17e8376cc202881aa62578062 Mon Sep 17 00:00:00 2001 From: Kayo Kallas Date: Sat, 7 Nov 2020 10:53:53 -0800 Subject: [PATCH 6/7] add log info --- ait/gui/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ait/gui/__init__.py b/ait/gui/__init__.py index 032a5b28..37f30e64 100644 --- a/ait/gui/__init__.py +++ b/ait/gui/__init__.py @@ -280,7 +280,10 @@ def __init__(self, inputs, outputs, zmq_args=None, **kwargs): try: HTMLRoot.User = kwargs['html']['directory'] + log.info('[GUI Plugin Configuration] Static file directory is set to {}'.format(HTMLRoot.User)) except: + log.warn('[GUI Plugin Configuration] Unable to locate static file direcotry in config.yaml. '\ + 'The directory is set to {}'.format(HTMLRoot.User)) pass bottle.TEMPLATE_PATH.append(HTMLRoot.User) From a6a5ab03dcf51b7fdf195b874c3506b19b394233 Mon Sep 17 00:00:00 2001 From: Kayo Kallas Date: Mon, 9 Nov 2020 12:39:43 -0800 Subject: [PATCH 7/7] Issue #138 - remove pass --- ait/gui/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ait/gui/__init__.py b/ait/gui/__init__.py index 37f30e64..4c0d7438 100644 --- a/ait/gui/__init__.py +++ b/ait/gui/__init__.py @@ -284,7 +284,6 @@ def __init__(self, inputs, outputs, zmq_args=None, **kwargs): except: log.warn('[GUI Plugin Configuration] Unable to locate static file direcotry in config.yaml. '\ 'The directory is set to {}'.format(HTMLRoot.User)) - pass bottle.TEMPLATE_PATH.append(HTMLRoot.User)