From d11ec7579cb621e376cfb233f00536b29610deb7 Mon Sep 17 00:00:00 2001 From: Akash Dhruv Date: Mon, 29 Jan 2024 23:29:49 -0600 Subject: [PATCH] experimental tweak to enable interactive shell output --- jobrunner/__meta__.py | 2 +- jobrunner/lib/_console.py | 32 +++++++++++++++++++++----------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/jobrunner/__meta__.py b/jobrunner/__meta__.py index 78a69b4..ab27af6 100644 --- a/jobrunner/__meta__.py +++ b/jobrunner/__meta__.py @@ -1,7 +1,7 @@ """Metadata for jobrunner""" __pkgname__ = "PyJobRunner" -__version__ = "2023.12.1" +__version__ = "2024.01" __authors__ = "Akash Dhruv" __license__ = "Apache Software License" __copyright__ = "Copyright (c) Akash Dhruv 2023. All Rights Reserved." diff --git a/jobrunner/lib/_console.py b/jobrunner/lib/_console.py index dd547e7..68d5cfb 100644 --- a/jobrunner/lib/_console.py +++ b/jobrunner/lib/_console.py @@ -49,18 +49,28 @@ def BashProcess(basedir, workdir, script, verbose=False, exit_on_failure=False): ) if verbose: - process = subprocess.Popen( - f"bash {script}".split(), - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - text=True, - ) - with open("job.output", "w") as output: - while process.poll() == None: - line = process.stdout.readline() - print(line.strip("\n")) - output.write(line) + # DEVNOTE (01/29/2024): Replacing the Popen command with run command + # to allow for interactive shell in verbose mode + # + + # DEVNOTE (01/29/2024): interactive shell + process = subprocess.run(f"bash {script}".split()) + + # DEVNOTE (01/29/2024): non-interactive process (needs fixing) + # + # process = subprocess.Popen( + # f"bash {script}".split(), + # stdout=subprocess.PIPE, + # stderr=subprocess.STDOUT, + # text=True, + # ) + + # with open("job.output", "w") as output: + # while process.poll() == None: + # line = process.stdout.readline() + # print(line.strip("\n")) + # output.write(line) else: with open("job.output", "w") as output: