Skip to content

Commit fe715e4

Browse files
authored
Merge pull request #442 from NeuroML/experimental
Add example testing execute_command_in_dir etc.
2 parents 0f2793c + 3c10a56 commit fe715e4

File tree

5 files changed

+26
-6
lines changed

5 files changed

+26
-6
lines changed

examples/test_execute_command.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from pyneuroml import pynml
2+
3+
run_dir = '.'
4+
5+
commands = ['pwd', 'ls -alt testss']
6+
7+
for command in commands:
8+
9+
print("\n====================\n")
10+
11+
returncode, output = pynml.execute_command_in_dir(command, run_dir, prefix="Output [%s] > "%command, verbose=True)
12+
13+
print(' ---- Return code from execute_command_in_dir: %s; output: \n%s\n--------------------------'%(returncode, output))
14+
15+
success = pynml.execute_command_in_dir_with_realtime_output(command, run_dir, prefix="Output [%s]: "%command, verbose=False)
16+
17+
print(' ---- Success of execute_command_in_dir_with_realtime_output: %s'%success)

pyneuroml/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
__version__ = importlib_metadata.version("pyNeuroML")
1313

1414

15-
JNEUROML_VERSION = "0.13.3"
15+
JNEUROML_VERSION = "0.14.0"
1616

1717
logger = logging.getLogger(__name__)
1818
logger.propagate = False

pyneuroml/runners.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ def execute_command_in_dir_with_realtime_output(
902902
)
903903
with p.stdout:
904904
for line in iter(p.stdout.readline, ""):
905-
print("# %s" % line.strip())
905+
print(" %s %s" % (prefix,line.strip()))
906906
p.wait() # wait for the subprocess to exit
907907

908908
print("####################################################################")
@@ -920,7 +920,7 @@ def execute_command_in_dir_with_realtime_output(
920920

921921
if not p.returncode == 0:
922922
logger.critical(
923-
"*** Problem running command (return code: %s): \n %s"
923+
"*** Problem running command (return code: %s): [%s]"
924924
% (p.returncode, command)
925925
)
926926

@@ -990,10 +990,13 @@ def execute_command_in_dir(
990990
return return_string.decode("utf-8")
991991

992992
except subprocess.CalledProcessError as e:
993-
logger.critical("*** Problem running command: \n %s" % e)
994-
logger.critical(
993+
logger.critical("*** Problem running last command: %s" % e)
994+
995+
print("####################################################################")
996+
print(
995997
"%s%s" % (prefix, e.output.decode().replace("\n", "\n" + prefix))
996998
)
999+
print("####################################################################")
9971000
return (e.returncode, e.output.decode())
9981001
except Exception as e:
9991002
logger.critical("*** Unknown problem running command: %s" % e)

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = pyNeuroML
3-
version = 1.3.14
3+
version = 1.3.15
44
author = Padraig Gleeson
55
author_email = p.gleeson@gmail.com
66
url = https://github.com/NeuroML/pyNeuroML

0 commit comments

Comments
 (0)