From f2029b4ec487246fd1d4b39a9e479eab153b0e88 Mon Sep 17 00:00:00 2001 From: "Juergen E. Fischer" Date: Thu, 24 Jan 2013 03:08:20 +0100 Subject: [PATCH] log python warnings and enabled deprecation warnings --- cmake/SIPMacros.cmake | 2 +- python/utils.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cmake/SIPMacros.cmake b/cmake/SIPMacros.cmake index 4cb7de4a8f1..4acbe7566f2 100644 --- a/cmake/SIPMacros.cmake +++ b/cmake/SIPMacros.cmake @@ -105,7 +105,7 @@ MACRO(ADD_SIP_PYTHON_MODULE MODULE_NAME MODULE_SIP) OUTPUT ${_sip_output_files} COMMAND ${CMAKE_COMMAND} -E echo ${message} COMMAND ${CMAKE_COMMAND} -E touch ${_sip_output_files} - COMMAND ${SIP_BINARY_PATH} ${_sip_tags} -e ${_sip_x} ${SIP_EXTRA_OPTIONS} -j ${SIP_CONCAT_PARTS} -c ${CMAKE_CURRENT_BINARY_DIR}/${_module_path} ${_sip_includes} ${_abs_module_sip} + COMMAND ${SIP_BINARY_PATH} ${_sip_tags} -w -e ${_sip_x} ${SIP_EXTRA_OPTIONS} -j ${SIP_CONCAT_PARTS} -c ${CMAKE_CURRENT_BINARY_DIR}/${_module_path} ${_sip_includes} ${_abs_module_sip} DEPENDS ${_abs_module_sip} ${SIP_EXTRA_FILES_DEPEND} ) # not sure if type MODULE could be uses anywhere, limit to cygwin for now diff --git a/python/utils.py b/python/utils.py index 0f282c49d82..699b6c50371 100755 --- a/python/utils.py +++ b/python/utils.py @@ -28,8 +28,8 @@ QGIS utilities module """ -from PyQt4.QtCore import QCoreApplication,QLocale, QString -from qgis.core import QGis, QgsExpression +from PyQt4.QtCore import QCoreApplication, QLocale, QString +from qgis.core import QGis, QgsExpression, QgsMessageLog from string import Template import sys import traceback @@ -37,10 +37,20 @@ import glob import os.path import re import ConfigParser +import warnings ####################### # ERROR HANDLING +warnings.simplefilter('default') + +def showWarning(message, category, filename, lineno, file=None, line=None): + QgsMessageLog.logMessage( + warnings.formatwarning(message, category, filename, lineno), + QCoreApplication.translate( "Python", "Python" ) + ) +warnings.showwarning = showWarning + def showException(type, value, tb, msg): lst = traceback.format_exception(type, value, tb) if msg == None: