Skip to content
Snippets Groups Projects
Commit ebf99eef authored by Mads M. Pedersen's avatar Mads M. Pedersen
Browse files

clean up simulation.py

parent 4fd30d12
No related branches found
No related tags found
No related merge requests found
...@@ -458,11 +458,7 @@ class SimulationThread(Thread): ...@@ -458,11 +458,7 @@ class SimulationThread(Thread):
stdout = self.sim.stdout_filename stdout = self.sim.stdout_filename
if not os.path.isdir(os.path.dirname(self.modelpath + self.sim.stdout_filename)): if not os.path.isdir(os.path.dirname(self.modelpath + self.sim.stdout_filename)):
os.makedirs(os.path.dirname(self.modelpath + self.sim.stdout_filename)) os.makedirs(os.path.dirname(self.modelpath + self.sim.stdout_filename))
#if os.name == "nt":
# self.process = subprocess.Popen('"%s" %s 1> %s 2>&1' % (hawc2exe, htcfile, stdout), stdout=None, stderr=None, shell=True, cwd=modelpath) #, creationflags=CREATE_NO_WINDOW)
#else:
# self.process = subprocess.Popen('wine "%s" %s 1> %s 2>&1' % (hawc2exe, htcfile, stdout), stdout=None, stderr=None, shell=True, cwd=modelpath)
with open (os.path.join(self.modelpath, stdout), 'wb') as stdout: with open (os.path.join(self.modelpath, stdout), 'wb') as stdout:
if isinstance(hawc2exe, tuple): if isinstance(hawc2exe, tuple):
wine, hawc2exe = hawc2exe wine, hawc2exe = hawc2exe
...@@ -471,15 +467,6 @@ class SimulationThread(Thread): ...@@ -471,15 +467,6 @@ class SimulationThread(Thread):
self.process = subprocess.Popen([hawc2exe, htcfile], stdout=stdout, stderr=STDOUT, shell=False, cwd=modelpath) #, creationflags=CREATE_NO_WINDOW) self.process = subprocess.Popen([hawc2exe, htcfile], stdout=stdout, stderr=STDOUT, shell=False, cwd=modelpath) #, creationflags=CREATE_NO_WINDOW)
self.process.communicate() self.process.communicate()
# if isinstance(hawc2exe, tuple):
# self.process = subprocess.Popen('%s "%s" %s 1> %s 2>&1' % (hawc2exe + (htcfile, stdout)), stdout=None, stderr=None, shell=False, cwd=modelpath)
# else:
# self.process = subprocess.Popen('"%s" %s 1> %s 2>&1' % (hawc2exe, htcfile, stdout), stdout=None, stderr=None, shell=False, cwd=modelpath) #, creationflags=CREATE_NO_WINDOW)
# with open("cmd.txt", 'w') as fid:
# fid.write("cd %s\n" % modelpath)
# fid.write('"%s" %s 1> %s 2>&1' % (hawc2exe, htcfile, stdout))
import psutil import psutil
try: try:
self.sim.host.resource.process_name = psutil.Process(self.process.pid).name() self.sim.host.resource.process_name = psutil.Process(self.process.pid).name()
......
...@@ -35,6 +35,8 @@ def set_cache_property(obj, name, get_func, set_func=None): ...@@ -35,6 +35,8 @@ def set_cache_property(obj, name, get_func, set_func=None):
>>> e = Example() >>> e = Example()
>>> e.test # Call, store and return result of e.slow_function >>> e.test # Call, store and return result of e.slow_function
>>> e.test # Return stored result of e.slow_function >>> e.test # Return stored result of e.slow_function
>>> e._test = None # clear cache result
>>> e.test # Call, store and return result of e.slow_function
""" """
_name = "_" + name _name = "_" + name
setattr(obj, _name, None) setattr(obj, _name, None)
......
...@@ -382,7 +382,8 @@ def py2pyx(pylines): ...@@ -382,7 +382,8 @@ def py2pyx(pylines):
cdef = l[l.index("#c") + 1:] cdef = l[l.index("#c") + 1:]
l = indent + cdef l = indent + cdef
if "__future__" in l: if "__future__" in l:
pyxlines.insert(0, l) # from __future__ import ... must be first #pyxlines.insert(0, l) # from __future__ import ... must be first
pass
else: else:
pyxlines.append(l) pyxlines.append(l)
return pyxlines return pyxlines
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment