Skip to content
Snippets Groups Projects
Commit 4b7a46b6 authored by Christoph.Knote's avatar Christoph.Knote
Browse files

OK, it won't work, probably, but it's a first try.

parent 999b34e5
Branches
Tags
No related merge requests found
...@@ -112,6 +112,8 @@ class Experiment: ...@@ -112,6 +112,8 @@ class Experiment:
#: Log file of the last run #: Log file of the last run
self.lastLog = None self.lastLog = None
self.pid = None
self.__new() self.__new()
#: Namelist #: Namelist
...@@ -184,11 +186,12 @@ class Experiment: ...@@ -184,11 +186,12 @@ class Experiment:
return mech return mech
def run(self, dumbOutput=False): def run(self, dumbOutput=False, asynchronous=False):
''' '''
Run BOXMOX experiment Run BOXMOX experiment
:param bool dumbOutput: Only load references to output files, instead of loading data? (faster, but not usable for analysis) :param bool dumbOutput: Only load references to output files, instead of loading data? (faster, but not usable for analysis)
:param bool asynchronous: Run asynchronous?
''' '''
self.namelist.write(os.path.join(self.path, 'BOXMOX.nml')) self.namelist.write(os.path.join(self.path, 'BOXMOX.nml'))
...@@ -200,11 +203,13 @@ class Experiment: ...@@ -200,11 +203,13 @@ class Experiment:
os.chdir(self.path) os.chdir(self.path)
try: try:
p = s.Popen("./" + self.mechanism + ".exe", stdout=s.PIPE, bufsize=1) self.pid = s.Popen("./" + self.mechanism + ".exe", stdout=s.PIPE, bufsize=1)
p.wait() # wait for the subprocess to exit if asynchronous:
return
self.pid.wait() # wait for the subprocess to exit
self.lastLog = [] self.lastLog = []
for line in iter(p.stdout.readline, b''): for line in iter(self.pid.stdout.readline, b''):
self.lastLog.append(line.replace('\n','')) self.lastLog.append(line.replace('\n',''))
except Exception as e: except Exception as e:
...@@ -293,6 +298,8 @@ class ExperimentFromExample(Experiment): ...@@ -293,6 +298,8 @@ class ExperimentFromExample(Experiment):
self.lastLog = None self.lastLog = None
self.pid = None
self.input = {} self.input = {}
self.output = {} self.output = {}
...@@ -333,6 +340,8 @@ class ExperimentFromExistingRun(Experiment): ...@@ -333,6 +340,8 @@ class ExperimentFromExistingRun(Experiment):
self.lastLog = None self.lastLog = None
self.pid = None
self.input = {} self.input = {}
self.output = {} self.output = {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment