From ebf99eef3f3c67ee3d978c26ff657cadbd8ddc00 Mon Sep 17 00:00:00 2001
From: "Mads M. Pedersen" <mmpe@dtu.dk>
Date: Thu, 3 Nov 2016 13:40:15 +0100
Subject: [PATCH] clean up simulation.py

---
 wetb/hawc2/simulation.py                    | 15 +--------------
 wetb/utils/caching.py                       |  2 ++
 wetb/utils/cython_compile/cython_compile.py |  3 ++-
 3 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/wetb/hawc2/simulation.py b/wetb/hawc2/simulation.py
index 4de23bab..01ae9412 100755
--- a/wetb/hawc2/simulation.py
+++ b/wetb/hawc2/simulation.py
@@ -458,11 +458,7 @@ class SimulationThread(Thread):
         stdout = 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))
-        #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:
             if isinstance(hawc2exe, tuple):
                 wine, hawc2exe = hawc2exe
@@ -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.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
         try:
             self.sim.host.resource.process_name = psutil.Process(self.process.pid).name()
diff --git a/wetb/utils/caching.py b/wetb/utils/caching.py
index 84a38a69..1ca38d4b 100644
--- a/wetb/utils/caching.py
+++ b/wetb/utils/caching.py
@@ -35,6 +35,8 @@ def set_cache_property(obj, name, get_func, set_func=None):
     >>> e = Example()
     >>> e.test # Call, store and return 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
     setattr(obj, _name, None)
diff --git a/wetb/utils/cython_compile/cython_compile.py b/wetb/utils/cython_compile/cython_compile.py
index 1e17e16f..f66ab60a 100644
--- a/wetb/utils/cython_compile/cython_compile.py
+++ b/wetb/utils/cython_compile/cython_compile.py
@@ -382,7 +382,8 @@ def py2pyx(pylines):
             cdef = l[l.index("#c") + 1:]
             l = indent + cdef
         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:
             pyxlines.append(l)
     return pyxlines
-- 
GitLab