[GRASS-SVN] r32359 - in grass/trunk/gui/wxpython: gui_modules nviz
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jul 29 09:12:19 EDT 2008
Author: martinl
Date: 2008-07-29 09:12:19 -0400 (Tue, 29 Jul 2008)
New Revision: 32359
Modified:
grass/trunk/gui/wxpython/gui_modules/goutput.py
grass/trunk/gui/wxpython/gui_modules/nviz.py
grass/trunk/gui/wxpython/nviz/init.cpp
Log:
wxGUI: message redirection fixes (need some more testing)
Modified: grass/trunk/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/goutput.py 2008-07-29 13:06:05 UTC (rev 32358)
+++ grass/trunk/gui/wxpython/gui_modules/goutput.py 2008-07-29 13:12:19 UTC (rev 32359)
@@ -58,7 +58,6 @@
# redirect
self.cmd_stdout = GMStdout(self.cmd_output)
- ### sys.stdout = self.cmd_stdout
self.cmd_stderr = GMStderr(self.cmd_output,
self.console_progressbar,
self.parent.notebook,
@@ -105,8 +104,9 @@
"""
if Debug.get_level() == 0:
# don't redirect when debugging is enabled
+ sys.stdout = self.cmd_stdout
sys.stderr = self.cmd_stderr
-
+
return True
return False
@@ -361,7 +361,7 @@
self.gmstc = gmstc
def write(self, s):
- if len(s) == 0:
+ if len(s) == 0 or s == '\n':
return
s = s.replace('\n', os.linesep)
for line in s.split(os.linesep):
@@ -402,7 +402,7 @@
s = s.replace('\n', os.linesep)
# remove/replace escape sequences '\b' or '\r' from stream
s = s.replace('\b', '').replace('\r', '%s' % os.linesep)
-
+
for line in s.split(os.linesep):
if len(line) == 0:
continue
@@ -416,19 +416,13 @@
self.gmgauge.SetValue(0) # reset progress bar on '0%'
elif 'GRASS_INFO_MESSAGE' in line:
self.type = 'message'
- if len(self.message) > 0:
- self.message += os.linesep
- self.message += line.split(':', 1)[1].strip()
+ self.message = line.split(':', 1)[1].strip()
elif 'GRASS_INFO_WARNING' in line:
self.type = 'warning'
- if len(self.message) > 0:
- self.message += os.linesep
- self.message += line.split(':', 1)[1].strip()
+ self.message = line.split(':', 1)[1].strip()
elif 'GRASS_INFO_ERROR' in line:
self.type = 'error'
- if len(self.message) > 0:
- self.message += os.linesep
- self.message += line.split(':', 1)[1].strip()
+ self.message = line.split(':', 1)[1].strip()
elif 'GRASS_INFO_END' in line:
self.printMessage = True
elif not self.type:
@@ -440,7 +434,7 @@
self.gmstc.StartStyling(p1, 0xff)
self.gmstc.SetStyling(p2 - p1 + 1, self.gmstc.StyleUnknown)
elif len(line) > 0:
- self.message += os.linesep + line.strip()
+ self.message += line.strip() + os.linesep
if self.printMessage and len(self.message) > 0:
p1 = self.gmstc.GetCurrentPos()
@@ -451,7 +445,7 @@
if os.linesep not in self.message:
self.gmstc.AddTextWrapped(self.message, wrap=60) #wrap && add os.linesep
else:
- self.gmstc.AddText(self.message + os.linesep)
+ self.gmstc.AddText(self.message)
self.gmstc.EnsureCaretVisible()
p2 = self.gmstc.GetCurrentPos()
self.gmstc.StartStyling(p1, 0xff)
@@ -464,6 +458,7 @@
self.type = ''
self.message = ''
+ self.printMessage = False
class GMStc(wx.stc.StyledTextCtrl):
"""Styled GMConsole
Modified: grass/trunk/gui/wxpython/gui_modules/nviz.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz.py 2008-07-29 13:06:05 UTC (rev 32358)
+++ grass/trunk/gui/wxpython/gui_modules/nviz.py 2008-07-29 13:12:19 UTC (rev 32359)
@@ -349,7 +349,7 @@
if type == 'raster':
self.LoadRaster(item)
except gcmd.NvizError, e:
- print >> sys.stderr, "Nviz: " + e.message
+ print >> sys.stderr, "Nviz:" + e.message
try:
if type == 'vector':
@@ -361,7 +361,7 @@
vecType.append(v)
self.LoadVector(item, vecType)
except gcmd.NvizError, e:
- print >> sys.stderr, "Nviz: " + e.message
+ print >> sys.stderr, "Nviz:" + e.message
stop = time.time()
@@ -439,7 +439,7 @@
id = self.nvizClass.LoadSurface(str(layer.name), None, None)
if id < 0:
- print >> sys.stderr, _("Loading raster map <%s> failed") % layer.name
+ print >> sys.stderr, "Nviz:" + _("Loading raster map <%s> failed") % layer.name
self.layers['raster']['name'].append(layer.name)
self.layers['raster']['id'].append(id)
@@ -474,9 +474,9 @@
id = data['surface']['object']['id']
if self.nvizClass.UnloadSurface(id) == 0:
- print >> sys.stderr, _("Unable to unload raster map <%s>") % layer.name
+ print >> sys.stderr, "Nviz:" + _("Unable to unload raster map <%s>") % layer.name
else:
- print _("Raster map <%s> unloaded") % layer.name
+ print "Nviz:" + _("Raster map <%s> unloaded successfully") % layer.name
data['surface'].pop('object')
@@ -629,7 +629,7 @@
id = self.nvizClass.LoadVector(str(layer.name), True)
if id < 0:
- print >> sys.stderr, _("Loading vector map <%s> (%s) failed") % \
+ print >> sys.stderr, "Nviz:" + _("Loading vector map <%s> (%s) failed") % \
(layer.name, type)
continue
@@ -679,10 +679,10 @@
else:
ret = self.nvizClass.UnloadVector(id, True)
if ret == 0:
- print >> sys.stderr, _("Unable to unload vector map <%s> (%s)") % \
+ print >> sys.stderr, "Nviz:" + _("Unable to unload vector map <%s> (%s)") % \
(layer.name, vtype)
else:
- print >> sys.stderr, _("Vector map <%s> (%s) unloaded") % \
+ print "Nviz:" + _("Vector map <%s> (%s) unloaded successfully") % \
(layer.name, vtype)
Modified: grass/trunk/gui/wxpython/nviz/init.cpp
===================================================================
--- grass/trunk/gui/wxpython/nviz/init.cpp 2008-07-29 13:06:05 UTC (rev 32358)
+++ grass/trunk/gui/wxpython/nviz/init.cpp 2008-07-29 13:12:19 UTC (rev 32359)
@@ -172,13 +172,13 @@
switch ( type ) {
case MSG:
- sprintf (prefix, "GRASS_INFO_MESSAGE(%d,%d): ", getpid(), message_id);
+ sprintf (prefix, "GRASS_INFO_MESSAGE(%d,%d): Nviz: ", getpid(), message_id);
break;
case WARN:
- sprintf (prefix, "GRASS_INFO_WARNING(%d,%d): ", getpid(), message_id);
+ sprintf (prefix, "GRASS_INFO_WARNING(%d,%d): Nviz: ", getpid(), message_id);
break;
case ERR:
- sprintf (prefix, "GRASS_INFO_ERROR(%d,%d): ", getpid(), message_id);
+ sprintf (prefix, "GRASS_INFO_ERROR(%d,%d): Nviz: ", getpid(), message_id);
break;
}
More information about the grass-commit
mailing list