[cig-commits] r11825 - cs/portal/trunk

leif at geodynamics.org leif at geodynamics.org
Thu Apr 17 17:13:02 PDT 2008


Author: leif
Date: 2008-04-17 17:13:02 -0700 (Thu, 17 Apr 2008)
New Revision: 11825

Modified:
   cs/portal/trunk/mineos.py
Log:
Wait for 'green' child process.


Modified: cs/portal/trunk/mineos.py
===================================================================
--- cs/portal/trunk/mineos.py	2008-04-17 19:47:51 UTC (rev 11824)
+++ cs/portal/trunk/mineos.py	2008-04-18 00:13:02 UTC (rev 11825)
@@ -86,7 +86,8 @@
         for dbname in self.eigcon_out:
             print >>s, dbname
         green_in = open("green.in", "w")
-        child = popen2.Popen4([os.path.join(self.bin, "green")])
+        argv = [os.path.join(self.bin, "green")]
+        child = popen2.Popen4(argv)
         for s in [green_in, child.tochild]:
             print >>s, self.stations
             print >>s, "db_list"
@@ -106,6 +107,8 @@
                 if now - lastPostTime >= 60.0:
                     self.postProgress(float(stationTally) / float(nStations))
                     lastPostTime = now
+        status = child.wait()
+        self.checkStatus(status, argv)
         return
 
 
@@ -144,17 +147,7 @@
         if pid:
             # parent
             _, status = os.wait()
-            exitStatus = None
-            if (os.WIFSIGNALED(status)):
-                statusStr = "signal %d" % os.WTERMSIG(status)
-            elif (os.WIFEXITED(status)):
-                exitStatus = os.WEXITSTATUS(status)
-                statusStr = "exit %d" % exitStatus
-            else:
-                statusStr = "status %d" % status
-            statusMsg = "%s: %s" % (argv[0], statusStr)
-            if exitStatus != 0:
-                sys.exit(statusMsg)
+            self.checkStatus(status, argv)
         else:
             # child
             if stdin is not None:
@@ -175,6 +168,21 @@
         return
 
 
+    def checkStatus(self, status, argv):
+        exitStatus = None
+        if (os.WIFSIGNALED(status)):
+            statusStr = "signal %d" % os.WTERMSIG(status)
+        elif (os.WIFEXITED(status)):
+            exitStatus = os.WEXITSTATUS(status)
+            statusStr = "exit %d" % exitStatus
+        else:
+            statusStr = "status %d" % status
+        statusMsg = "%s: %s" % (argv[0], statusStr)
+        if exitStatus != 0:
+            sys.exit(statusMsg)
+        return
+
+
     def lineCount(self, filename):
         tally = 0
         s = open(filename, 'r')



More information about the cig-commits mailing list