Skip to content

Commit

Permalink
experimental tweak to enable interactive shell output
Browse files Browse the repository at this point in the history
  • Loading branch information
akashdhruv committed Jan 30, 2024
1 parent 60fe90b commit d11ec75
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion jobrunner/__meta__.py
Original file line number Diff line number Diff line change
@@ -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."
Expand Down
32 changes: 21 additions & 11 deletions jobrunner/lib/_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit d11ec75

Please sign in to comment.