Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions examples/test_data/realtime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from pyneuroml import pynml


command = 'python snooze.py'
run_dir = '.'

oo = pynml.execute_command_in_dir_with_realtime_output(command, run_dir, verbose=True)

print(oo)
9 changes: 9 additions & 0 deletions examples/test_data/snooze.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import time

print("zzz")
time.sleep(1)
print("hrnmm...")
time.sleep(1)
print("zzz")
time.sleep(1)
print("yawn...")
8 changes: 6 additions & 2 deletions pyneuroml/pynml.py
Original file line number Diff line number Diff line change
Expand Up @@ -2419,7 +2419,9 @@ def execute_command_in_dir_with_realtime_output(
if os.name == "nt":
directory = os.path.normpath(directory)

logger.info("Executing: (%s) in directory: %s" % (command, directory))
print("####################################################################")
print("# pyNeuroML executing: (%s) in directory: %s" % (command, directory))
print("####################################################################")
if env is not None:
logger.info("Extra env variables %s" % (env))

Expand All @@ -2436,8 +2438,10 @@ def execute_command_in_dir_with_realtime_output(
)
with p.stdout:
for line in iter(p.stdout.readline, ""):
logger.debug(line.strip())
print("# %s"%line.strip())
p.wait() # wait for the subprocess to exit

print("####################################################################")
except KeyboardInterrupt as e:
logger.error("*** Command interrupted: \n %s" % command)
if p:
Expand Down