From 63e4d535a9564804a2d5026bbf45203175d8be77 Mon Sep 17 00:00:00 2001 From: gzukowski Date: Mon, 26 Jun 2023 13:24:19 +0000 Subject: [PATCH 1/2] Fixed bug with missing content-type --- packages/python-runner/runner.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/python-runner/runner.py b/packages/python-runner/runner.py index 73e1d65eb..06770260b 100644 --- a/packages/python-runner/runner.py +++ b/packages/python-runner/runner.py @@ -181,6 +181,7 @@ def load_sequence(self): sys.path.append(module_dir) self.logger.debug(f'Loading sequence from {self.seq_path}...') spec = importlib.util.spec_from_file_location('sequence', self.seq_path) + self.logger.info(f"spec: {spec}") self.sequence = importlib.util.module_from_spec(spec) spec.loader.exec_module(self.sequence) self.logger.info(f'Sequence loaded: {self.sequence}') @@ -197,8 +198,8 @@ async def run_instance(self, config, args): self.logger.info(f'Sending PANG') monitoring = self.streams[CC.MONITORING] - produces = getattr(result, 'provides', None) or getattr(self.sequence, 'provides', None) + content_type = getattr(result, 'contentType', None) or getattr(self.sequence, 'provides', None) if produces: self.logger.info(f'Sending PANG with {produces}') send_encoded_msg(monitoring, msg_codes.PANG, produces) @@ -250,17 +251,19 @@ async def connect_input_stream(self, input_stream): async def forward_output_stream(self, output): - if hasattr(output, 'content_type'): - content_type = output.content_type + + if hasattr(output, 'provides'): + attribute = getattr(self.sequence, 'provides', None) + content_type = attribute['contentType'] else: - # Deprecated - if hasattr(self.sequence, 'output_type'): - content_type = self.sequence.output_type + if hasattr(self.sequence, 'provides'): + attribute = getattr(self.sequence, 'provides', None) + content_type = attribute['contentType'] else: self.logger.debug('Output type not set, using default') content_type = 'text/plain' + self.logger.info(f'Content-type: {content_type}') - if content_type == 'text/plain': self.logger.debug('Output stream will be treated as text and encoded') output = output.map(lambda s: s.encode()) From 88b2a31cdd38017bf66336e059ef209337b78125 Mon Sep 17 00:00:00 2001 From: gzukowski Date: Tue, 27 Jun 2023 10:08:57 +0000 Subject: [PATCH 2/2] Removed debug leftover --- packages/python-runner/runner.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/python-runner/runner.py b/packages/python-runner/runner.py index 06770260b..a2c2a369f 100644 --- a/packages/python-runner/runner.py +++ b/packages/python-runner/runner.py @@ -181,7 +181,6 @@ def load_sequence(self): sys.path.append(module_dir) self.logger.debug(f'Loading sequence from {self.seq_path}...') spec = importlib.util.spec_from_file_location('sequence', self.seq_path) - self.logger.info(f"spec: {spec}") self.sequence = importlib.util.module_from_spec(spec) spec.loader.exec_module(self.sequence) self.logger.info(f'Sequence loaded: {self.sequence}') @@ -199,7 +198,6 @@ async def run_instance(self, config, args): self.logger.info(f'Sending PANG') monitoring = self.streams[CC.MONITORING] produces = getattr(result, 'provides', None) or getattr(self.sequence, 'provides', None) - content_type = getattr(result, 'contentType', None) or getattr(self.sequence, 'provides', None) if produces: self.logger.info(f'Sending PANG with {produces}') send_encoded_msg(monitoring, msg_codes.PANG, produces)