[Greater-commits] r3806 - trunk/greater-pre-processing

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Oct 13 20:37:39 CEST 2011


Author: aheinecke
Date: 2011-10-13 20:37:38 +0200 (Thu, 13 Oct 2011)
New Revision: 3806

Modified:
   trunk/greater-pre-processing/greater-pre-processing.py
Log:
Fix running of cygwin commands when cygwin not in
the environment.
Remove backup of the catchment.desc
Fix writing the upload catchment.desc


Modified: trunk/greater-pre-processing/greater-pre-processing.py
===================================================================
--- trunk/greater-pre-processing/greater-pre-processing.py	2011-10-13 18:30:59 UTC (rev 3805)
+++ trunk/greater-pre-processing/greater-pre-processing.py	2011-10-13 18:37:38 UTC (rev 3806)
@@ -16,7 +16,16 @@
 import subprocess
 
 import support
+_dir = os.path.join(sys.path[0], os.pardir)
+for reldir in ("Python", "GREAT-ER-DB", "GREAT-ERModel", "sciparam", "Lib",
+          os.path.join("GREAT-ERModel", "Lib"), "Thuban"):
+    fullname = os.path.join(_dir, reldir)
+    if os.path.isdir(fullname):
+        sys.path.append(fullname)
 
+# add ./bin to path to allow easier packaging
+os.environ["PATH"] = os.path.join(sys.path[0], "bin") + \
+                    ";" + os.environ["PATH"]
 import wxPython.wx as wx
 from wxPython.wizard import wxWizard, wxWizardPageSimple, \
      wxWizardPageSimple_Chain, EVT_WIZARD_PAGE_CHANGING, \
@@ -76,9 +85,6 @@
         for string in command:
             converted_command.append(string.replace('\\', '/'))
         command = converted_command
-        # add ./bin to path to allow easier packaging
-        extra_env["PATH"] = os.path.join(sys.path[0], "bin") + \
-                            ";" + os.environ["PATH"]
         extra_env["CYGWIN"] = "nodosfilewarning"
 
     if inputdata is not None:
@@ -466,9 +472,9 @@
 
     print ' Removing tmp-files and old log-file (' +catchment['ID'] + '.log ...'
     cmds = [ 'rm -f *.tmp ' + catchment['ID'] + '.log' ]
-    for cmd in cmds:
-        if cygwin_call(cmd) != 0:
-            raise OSError('  Error executing ' + cmd)
+#    for cmd in cmds:
+#        if cygwin_call(cmd) != 0:
+#            raise OSError('  Error executing ' + cmd)
     print ' done.'
     yield(7)
 
@@ -808,7 +814,7 @@
         except:
             bitmap = wx.wxNullBitmap
         wizard = self.wizard = wxWizard(wx.NULL, -1,
-                                        "GREAT-ER Pre Processing", bitmap)
+                                        "GREAT-ER Preprocessing", bitmap)
         intro_page = SimpleTextPage(wizard, "Welcome", intro)
         self.intro_page = intro_page
 
@@ -886,7 +892,7 @@
             except:
                 wx.wxMessageBox("An error occurred:\n%s"
                                 % str(sys.exc_info()[1]),
-                                "Error prerocessing Catchment.")
+                                "Error preprocessing Catchment.")
         finally:
             os.chdir(oldcwd)
             dialog.Destroy()
@@ -917,7 +923,7 @@
 
     upfile = os.path.join(cdir, "catchment.desc")
     with open(upfile, "w") as fptr:
-        upfile.write(OUTPUT_FILES)
+        fptr.write(OUTPUT_FILES)
 
 def write_desc(catchment_page):
     """ Tages a CatchmentPage and writes the description into the
@@ -940,31 +946,10 @@
 
     app = PreProcessingApp(0)
 
-    # Make a backup of the old catchment.desc
-    try:
-        old_catchment = os.path.join(self.wizard.catchment_page.catchment_dir,
-                "catchment.desc")
-        if os.path.isfile(old_catchment):
-            shutil.copyfile(old_catchment, old_catchment.replace(
-                "catchment.desc", "catchment.desc.bkp"))
-    except:
-        print "Error creating backup: ", str(sys.exc_info()[1])
+    success = app.RunWizard()
+    if not success:
+        sys.exit(1)
 
-    def restore_backup():
-        try:
-            shutil.move(old_catchment.replace(
-                "catchment.desc", "catchment.desc.bkp"), old_catchment)
-        except:
-            print "Error restoring backup: ", str(sys.exc_info()[1])
-
-    try:
-        success = app.RunWizard()
-        if not success:
-            restore_backup()
-            sys.exit(1)
-    except:
-        restore_backup()
-
 # Old console version main
 #if __name__ == '__main__':
 #    import sys



More information about the Greater-commits mailing list