Skip to content
Permalink
Browse files

added a quick fix for the unicode problem in log (now exceptions are …

…catched and ignored). this fixes #5882

git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@267 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
volayaf
volayaf committed Jun 27, 2012
1 parent 26b892e commit 0573907d219def67a7ce663bce5ff3792532180c
Showing with 20 additions and 16 deletions.
  1. +20 −14 src/sextante/core/SextanteLog.py
  2. +0 −2 src/sextante/gui/AlgorithmExecutor.py
@@ -28,20 +28,26 @@ def logFilename():

@staticmethod
def addToLog(msgtype, msg):
if isinstance(msg, list):
a = "|".join(m.strip("\n") for m in msg)
text = unicode(a)
else:
text = unicode(msg).replace("\n", "|")
line = msgtype + "|" + datetime.datetime.now().strftime("%a %b %d %Y %H:%M:%S") + "|" + text + "\n"
logfile = codecs.open(SextanteLog.logFilename(), "a", encoding='utf-8')
logfile.write(line)
logfile.close()
if msgtype==SextanteLog.LOG_ALGORITHM:
algname = text[len("Sextante.runalg(\""):]
algname = algname[:algname.index("\"")]
if algname not in SextanteLog.recentAlgs:
SextanteLog.recentAlgs.append(algname)
try: #it seems that this fails sometimes depending on the msg added:
#To avoid it stopping the normal functioning of the algorithm,
#we catch all errors, assuming that is better to miss some log info
#that breaking the algorithm.
if isinstance(msg, list):
a = "|".join(m.strip("\n") for m in msg)
text = unicode(a)
else:
text = unicode(msg).replace("\n", "|")
line = msgtype + "|" + datetime.datetime.now().strftime("%a %b %d %Y %H:%M:%S") + "|" + text + "\n"
logfile = codecs.open(SextanteLog.logFilename(), "a", encoding='utf-8')
logfile.write(line)
logfile.close()
if msgtype==SextanteLog.LOG_ALGORITHM:
algname = text[len("Sextante.runalg(\""):]
algname = algname[:algname.index("\"")]
if algname not in SextanteLog.recentAlgs:
SextanteLog.recentAlgs.append(algname)
except:
pass


@staticmethod
@@ -4,8 +4,6 @@
from sextante.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from sextante.core.QGisLayers import QGisLayers
from sextante.core.SextanteUtils import SextanteUtils
from sextante.gui.SextantePostprocessing import SextantePostprocessing
import traceback

class AlgorithmExecutor(QThread):
percentageChanged = pyqtSignal(int)

0 comments on commit 0573907

Please sign in to comment.
You can’t perform that action at this time.