This is an automated email from the ASF dual-hosted git repository.

rkk pushed a commit to branch tmp-stv
in repository https://gitbox.apache.org/repos/asf/sdap-nexus.git

commit eaf4d6b860b4cdeaf6d81d9188a63c8c9d5ad115
Author: rileykk <[email protected]>
AuthorDate: Mon Dec 11 10:33:34 2023 -0800

    Added GIF renderer
---
 ...NexusRendererFactory.py => NexusGIFRenderer.py} | 27 +++++++++++-----------
 .../request/renderers/NexusRendererFactory.py      |  2 +-
 .../nexus_tornado/request/renderers/__init__.py    |  3 ++-
 3 files changed, 17 insertions(+), 15 deletions(-)

diff --git 
a/analysis/webservice/nexus_tornado/request/renderers/NexusRendererFactory.py 
b/analysis/webservice/nexus_tornado/request/renderers/NexusGIFRenderer.py
similarity index 57%
copy from 
analysis/webservice/nexus_tornado/request/renderers/NexusRendererFactory.py
copy to analysis/webservice/nexus_tornado/request/renderers/NexusGIFRenderer.py
index e0dabe2..5645bd8 100644
--- 
a/analysis/webservice/nexus_tornado/request/renderers/NexusRendererFactory.py
+++ b/analysis/webservice/nexus_tornado/request/renderers/NexusGIFRenderer.py
@@ -13,19 +13,20 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-class NexusRendererFactory(object):
-    content_types = ["CSV", "JSON", "XML", "PNG", "NETCDF", "ZIP"]
-    module = __import__(__name__)
-
-    @classmethod
-    def get_renderer(cls, request):
-        content_type = request.get_content_type().upper()
-        if content_type in cls.content_types:
-            renderer_name = 'Nexus' + content_type + 'Renderer'
-            renderer = getattr(cls.module.nexus_tornado.request.renderers, 
renderer_name)
-            return renderer(request)
-
-
+import sys
+import traceback
+from webservice.webmodel import NexusProcessingException
 
 
+class NexusGIFRenderer(object):
+    def __init__(self, nexus_request):
+        self._request = nexus_request
 
+    def render(self, tornado_handler, result):
+        tornado_handler.set_header("Content-Type", "image/gif")
+        try:
+            tornado_handler.write(result.toGif())
+            tornado_handler.finish()
+        except AttributeError:
+            traceback.print_exc(file=sys.stdout)
+            raise NexusProcessingException(reason="Unable to convert results 
to a GIF.")
diff --git 
a/analysis/webservice/nexus_tornado/request/renderers/NexusRendererFactory.py 
b/analysis/webservice/nexus_tornado/request/renderers/NexusRendererFactory.py
index e0dabe2..b92abb4 100644
--- 
a/analysis/webservice/nexus_tornado/request/renderers/NexusRendererFactory.py
+++ 
b/analysis/webservice/nexus_tornado/request/renderers/NexusRendererFactory.py
@@ -14,7 +14,7 @@
 # limitations under the License.
 
 class NexusRendererFactory(object):
-    content_types = ["CSV", "JSON", "XML", "PNG", "NETCDF", "ZIP"]
+    content_types = ["CSV", "JSON", "XML", "PNG", "NETCDF", "ZIP", "GIF"]
     module = __import__(__name__)
 
     @classmethod
diff --git a/analysis/webservice/nexus_tornado/request/renderers/__init__.py 
b/analysis/webservice/nexus_tornado/request/renderers/__init__.py
index 4c1d31e..f520933 100644
--- a/analysis/webservice/nexus_tornado/request/renderers/__init__.py
+++ b/analysis/webservice/nexus_tornado/request/renderers/__init__.py
@@ -18,4 +18,5 @@ from .NexusJSONRenderer import NexusJSONRenderer
 from .NexusCSVRenderer import NexusCSVRenderer
 from .NexusNETCDFRenderer import NexusNETCDFRenderer
 from .NexusPNGRenderer import NexusPNGRenderer
-from .NexusZIPRenderer import NexusZIPRenderer
\ No newline at end of file
+from .NexusGIFRenderer import NexusGIFRenderer
+from .NexusZIPRenderer import NexusZIPRenderer

Reply via email to