Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

Commit

Permalink
Merge pull request #52 from ghrcdaac/mlh0079-5202-subprocess-logging
Browse files Browse the repository at this point in the history
 - Implemented workaround for python subprocess logging.
  • Loading branch information
camposeddie authored Jul 24, 2023
2 parents 33f82d7 + 1e2ad5b commit 3abe75a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions dmrpp_generator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ def __init__(self, **kwargs):
self.timeout = int(self.dmrpp_meta.get(
'get_dmrpp_timeout', os.getenv('GET_DMRPP_TIMEOUT', '60'))
)
self.enable_subprocess_logging = self.dmrpp_meta.get(
'enable_subprocess_logging', os.getenv('ENABLE_SUBPROCESS_LOGGING', False)
)

self.logger_to_cw.info(f'get_dmrpp_timeout: {self.timeout}')

@property
Expand Down Expand Up @@ -163,8 +167,15 @@ def add_missing_files(self, dmrpp_meta, file_name):

def run_command(self, cmd):
""" Run cmd as a system command """
out = subprocess.run(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE,
check=True, timeout=self.timeout)
stdout = None
stderr = None

if self.enable_subprocess_logging:
stdout = subprocess.PIPE
stderr = subprocess.STDOUT

out = subprocess.run(cmd.split(), stdout=stdout, stderr=stderr, timeout=self.timeout, check=True)

return out

def dmrpp_generate(self, input_file, local=False, dmrpp_meta=None):
Expand Down

0 comments on commit 3abe75a

Please sign in to comment.