Skip to content

Commit

Permalink
followup r13013 and implement #2539
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@13055 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Mar 15, 2010
1 parent b20baa8 commit b4f124b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions python/utils.py
Expand Up @@ -5,6 +5,7 @@
"""

from PyQt4.QtCore import QCoreApplication
from qgis.core import QGis
import sys
import traceback
import glob
Expand All @@ -23,6 +24,7 @@ def showException(type, value, tb, msg):
for s in lst:
txt += s
txt += '<br>%s<br>%s<br><br>' % (QCoreApplication.translate('Python','Python version:'), sys.version)
txt += '<br>%s<br>%s %s, %s<br><br>' % (QCoreApplication.translate('Python','QGIS version:'), QGis.QGIS_VERSION, QGis.QGIS_RELEASE_NAME, QGis.QGIS_SVN_VERSION)
txt += '%s %s' % (QCoreApplication.translate('Python','Python path:'), str(sys.path))
txt = txt.replace('\n', '<br>')
txt = txt.replace(' ', '&nbsp; ') # preserve whitespaces for nicer output
Expand Down
15 changes: 12 additions & 3 deletions src/python/qgspythonutilsimpl.cpp
Expand Up @@ -23,6 +23,7 @@
#endif
#include <Python.h>

#include "qgis.h"
#include "qgspythonutilsimpl.h"

#include "qgsapplication.h"
Expand Down Expand Up @@ -60,7 +61,14 @@ void QgsPythonUtilsImpl::initPython( QgisInterface* interface )

// expect that bindings are installed locally, so add the path to modules
// also add path to plugins
#ifdef Q_OS_WIN
runString( "if os.environ.has_key('HOME'): oldhome=os.environ['HOME']\n" );
runString( "os.environ['HOME']=os.environ['USERPROFILE']" );
#endif
runString( "sys.path = [\"" + pythonPath() + "\", os.path.expanduser(\"~/.qgis/python\"), os.path.expanduser(\"~/.qgis/python/plugins\"), \"" + pluginsPath() + "\" ] + sys.path" );
#ifdef Q_OS_WIN
runString( "if os.environ.has_key('HOME'): os.environ['HOME']=oldhome\n" );
#endif

// import SIP
if ( !runString( "from sip import wrapinstance, unwrapinstance",
Expand Down Expand Up @@ -152,9 +160,10 @@ bool QgsPythonUtilsImpl::runString( const QString& command, QString msgOnError )
evalString( "str(sys.path)", path );
evalString( "sys.version", version );

QString str = "<font color=\"red\">" + msgOnError + "</font><br><br>" + traceback + "<br>" +
QObject::tr( "Python version:" ) + "<br>" + version + "<br><br>" +
QObject::tr( "Python path:" ) + "<br>" + path;
QString str = "<font color=\"red\">" + msgOnError + "</font><br><br>" + traceback + "<br>"
+ QObject::tr( "Python version:" ) + "<br>" + version + "<br><br>"
+ QObject::tr( "QGIS version:" ) + "<br>" + QString( "%1 '%2', %3" ).arg( QGis::QGIS_VERSION ).arg( QGis::QGIS_RELEASE_NAME ).arg( QGis::QGIS_SVN_VERSION ) + "<br><br>"
+ QObject::tr( "Python path:" ) + "<br>" + path;
str.replace( "\n", "<br>" ).replace( " ", "&nbsp; " );

QgsMessageOutput* msg = QgsMessageOutput::createMessageOutput();
Expand Down

0 comments on commit b4f124b

Please sign in to comment.