Skip to content

Commit e38239e

Browse files
author
jef
committed
followup r13013 and implement #2539
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13055 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent a51e231 commit e38239e

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

python/utils.py

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66

77
from PyQt4.QtCore import QCoreApplication
8+
from qgis.core import QGis
89
import sys
910
import traceback
1011
import glob
@@ -23,6 +24,7 @@ def showException(type, value, tb, msg):
2324
for s in lst:
2425
txt += s
2526
txt += '<br>%s<br>%s<br><br>' % (QCoreApplication.translate('Python','Python version:'), sys.version)
27+
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)
2628
txt += '%s %s' % (QCoreApplication.translate('Python','Python path:'), str(sys.path))
2729
txt = txt.replace('\n', '<br>')
2830
txt = txt.replace(' ', '&nbsp; ') # preserve whitespaces for nicer output

src/python/qgspythonutilsimpl.cpp

+12-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#endif
2424
#include <Python.h>
2525

26+
#include "qgis.h"
2627
#include "qgspythonutilsimpl.h"
2728

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

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

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

155-
QString str = "<font color=\"red\">" + msgOnError + "</font><br><br>" + traceback + "<br>" +
156-
QObject::tr( "Python version:" ) + "<br>" + version + "<br><br>" +
157-
QObject::tr( "Python path:" ) + "<br>" + path;
163+
QString str = "<font color=\"red\">" + msgOnError + "</font><br><br>" + traceback + "<br>"
164+
+ QObject::tr( "Python version:" ) + "<br>" + version + "<br><br>"
165+
+ 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>"
166+
+ QObject::tr( "Python path:" ) + "<br>" + path;
158167
str.replace( "\n", "<br>" ).replace( " ", "&nbsp; " );
159168

160169
QgsMessageOutput* msg = QgsMessageOutput::createMessageOutput();

0 commit comments

Comments
 (0)