Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
py2/py3 compat patches
  • Loading branch information
m-kuhn committed Mar 22, 2016
1 parent 83d729c commit 02c5637
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 25 deletions.
26 changes: 13 additions & 13 deletions .travis.yml
Expand Up @@ -49,19 +49,19 @@ matrix:
git:
depth: 30

# notifications:
# irc: "chat.freenode.net#qgis-test"
# on_failure: change
# on_success: change
# skip_join: true
#
# notifications:
# webhooks:
# urls:
# - https://webhooks.gitter.im/e/467e3aff72e344d1dae3
# on_success: change # options: [always|never|change] default: always
# on_failure: always # options: [always|never|change] default: always
# on_start: never # default: never
notifications:
irc: "chat.freenode.net#qgis-test"
on_failure: change
on_success: change
skip_join: true

notifications:
webhooks:
urls:
- https://webhooks.gitter.im/e/467e3aff72e344d1dae3
on_success: change # options: [always|never|change] default: always
on_failure: always # options: [always|never|change] default: always
on_start: never # default: never

before_install:
- ./ci/travis/${TRAVIS_OS_NAME}/before_install.sh
Expand Down
2 changes: 1 addition & 1 deletion ci/travis/linux/qt4/before_install.sh
Expand Up @@ -66,7 +66,7 @@ sudo apt-get install --force-yes --no-install-recommends --no-install-suggests \
postgresql-9.1-postgis-2.1/precise # from ubuntugis-unstable, not pgdg

sudo -H pip install autopep8 # TODO when switching to trusty or above: replace python-pip with python-autopep8
sudo -H pip install nose2 pyyaml mock
sudo -H pip install nose2 pyyaml mock future

#update clang
sudo apt-get install --force-yes llvm-3.8 llvm-3.8-dev clang-3.8 libstdc++-4.9-dev
Expand Down
1 change: 0 additions & 1 deletion ci/travis/linux/qt5/blacklist.txt
Expand Up @@ -24,7 +24,6 @@ PyQgsDelimitedTextProvider
PyQgsDistanceArea
PyQgsDocCoverage
PyQgsEditWidgets
PyQgsExpression
PyQgsFeature
PyQgsFeatureIterator
PyQgsField
Expand Down
2 changes: 1 addition & 1 deletion ci/travis/osx/before_install.sh
Expand Up @@ -18,4 +18,4 @@ mkdir -p ${HOME}/Library/Python/2.7/lib/python/site-packages
echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> ${HOME}/Library/Python/2.7/lib/python/site-packages/homebrew.pth

# Needed for Processing
pip install psycopg2 numpy nose2 pyyaml mock
pip install psycopg2 numpy nose2 pyyaml mock future
29 changes: 22 additions & 7 deletions python/utils.py
Expand Up @@ -16,6 +16,10 @@
* *
***************************************************************************
"""
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()
from builtins import str

__author__ = 'Martin Dobias'
__date__ = 'November 2009'
Expand All @@ -37,7 +41,10 @@
import traceback
import glob
import os.path
import ConfigParser
try:
import configparser
except ImportError:
import ConfigParser as configparser
import warnings
import codecs
import time
Expand Down Expand Up @@ -237,7 +244,7 @@ def findPlugins(path):
if not os.path.exists(metadataFile):
continue

cp = ConfigParser.ConfigParser()
cp = configparser.ConfigParser()

try:
f = codecs.open(metadataFile, "r", "utf8")
Expand Down Expand Up @@ -476,7 +483,7 @@ def reloadProjectMacros():
mod = imp.new_module("proj_macros_mod")

# set the module code and store it sys.modules
exec(unicode(code), mod.__dict__)
exec(str(code), mod.__dict__)
sys.modules["proj_macros_mod"] = mod

# load new macros
Expand Down Expand Up @@ -574,9 +581,15 @@ def startServerPlugin(packageName):
#######################
# IMPORT wrapper

import __builtin__
try:
import builtins

_builtin_import = builtins.__import__
except AttributeError:
import __builtin__

_builtin_import = __builtin__.__import__

_builtin_import = __builtin__.__import__
_plugin_modules = {}


Expand All @@ -603,5 +616,7 @@ def _import(name, globals={}, locals={}, fromlist=[], level=None):

return mod


__builtin__.__import__ = _import
try:
builtins.__import__ = _import
except AttributeError:
__builtin__.__import__ = _import
2 changes: 2 additions & 0 deletions src/python/qgspythonutilsimpl.cpp
Expand Up @@ -32,6 +32,7 @@
#include <QMessageBox>
#include <QStringList>
#include <QDir>
#include <QDebug>

#if (PY_VERSION_HEX < 0x03000000)
#define PYOBJ2QSTRING(obj) PyString_AsString( obj )
Expand Down Expand Up @@ -335,6 +336,7 @@ bool QgsPythonUtilsImpl::runString( const QString& command, QString msgOnError,
+ QObject::tr( "Python path:" ) + "<br>" + path;
str.replace( '\n', "<br>" ).replace( " ", "&nbsp; " );

qDebug() << str;
QgsMessageOutput* msg = QgsMessageOutput::createMessageOutput();
msg->setTitle( QObject::tr( "Python error" ) );
msg->setMessage( str, QgsMessageOutput::MessageHtml );
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_qgsexpression.py
Expand Up @@ -150,7 +150,7 @@ def testBlockComment(self):
comment
**/""": 'test*/'
}
for e, exp_res in expressions.iteritems():
for e, exp_res in expressions.items():
exp = QgsExpression(e)
result = exp.evaluate()
self.assertEqual(exp_res, result)
Expand All @@ -164,7 +164,7 @@ def testComment(self):
"'test--'": 'test--',
"'--test'": '--test',
}
for e, exp_res in expressions.iteritems():
for e, exp_res in expressions.items():
exp = QgsExpression(e)
result = exp.evaluate()
self.assertEqual(exp_res, result)
Expand Down

0 comments on commit 02c5637

Please sign in to comment.