Skip to content

Commit

Permalink
added a quick fix for the unicode problem in log (now exceptions are …
Browse files Browse the repository at this point in the history
…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 committed Jun 27, 2012
1 parent 26b892e commit 0573907
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
34 changes: 20 additions & 14 deletions src/sextante/core/SextanteLog.py
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions src/sextante/gui/AlgorithmExecutor.py
Expand Up @@ -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)
Expand Down

0 comments on commit 0573907

Please sign in to comment.