dabo Commit
Revision 5119
Date: 2009-03-08 18:13:46 -0700 (Sun, 08 Mar 2009)
Author: Ed
Trac: http://trac.dabodev.com/changeset/5119
Changed:
U trunk/dabo/ui/uiwx/__init__.py
Log:
Improved the spawn process. Previously, issuing 'print' commands or any other
std.out process would somehow cause the Dabo pref file to become corrupted.
Empolying a redirected process fixes this symptom, but you still cannot print.
I can't find the documentation I need to figure out how I have to handle the
output stream.
Diff:
Modified: trunk/dabo/ui/uiwx/__init__.py
===================================================================
--- trunk/dabo/ui/uiwx/__init__.py 2009-03-07 15:08:02 UTC (rev 5118)
+++ trunk/dabo/ui/uiwx/__init__.py 2009-03-09 01:13:46 UTC (rev 5119)
@@ -1683,18 +1683,42 @@
dabo.ui.__dict__["dForm"] = dFormSDI
-def spawnProcess(cmd, wait=False):
+def spawnProcess(cmd, wait=False, handler=None):
"""Launch a separate process. Control is immediately returned to the
calling program, unless you call this with 'wait=True'.
"""
+ class Proc(wx.Process):
+ def __init__(self, parent, *args, **kwargs):
+ super(Proc, self).__init__(parent, *args, **kwargs)
+ self._handler = parent
+ def OnTerminate(self, pid, status):
+ if self._handler:
+ try:
+ handler.onProcTermintated(self, pid,
status)
+ except AttributeError:
+ pass
+ def read(self):
+ # This is still not working; I'm not sure how it's
supposed to work,
+ # based on the scanty documentation.
+ out = ""
+ stream = self.GetInputStream()
+ if stream.CanRead():
+ out = stream.read()
+ stream = self.GetErrorStream()
+ err = ""
+ if stream.CanRead():
+ err = "Errors:\n%s" % stream.read()
+ return (out, err)
+ proc = Proc(handler)
+ proc.Redirect()
if wait:
flag = wx.EXEC_SYNC
else:
flag = wx.EXEC_ASYNC
- return wx.Execute(cmd, flag)
+ pidOrResult = wx.Execute(cmd, flag, proc)
+ return pidOrResult, proc
-
class GridSizerSpanException(dabo.dException.dException):
"""Raised when an attempt is made to set the RowSpan or
ColSpan of an item to an illegal value.
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message:
http://leafe.com/archives/byMID/[email protected]