Skip to content

Commit

Permalink
Merge pull request #21 from eea/develop
Browse files Browse the repository at this point in the history
Develop #110159
  • Loading branch information
avoinea authored Feb 28, 2020
2 parents 6d7c8e3 + 5c336b0 commit 3640252
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 95 deletions.
53 changes: 32 additions & 21 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ pipeline {
"JS Hint": {
node(label: 'docker') {
script {
try {
catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE') {
sh '''docker run -i --rm --name="$BUILD_TAG-jshint" -e GIT_SRC="https://github.com/eea/$GIT_NAME.git" -e GIT_NAME="$GIT_NAME" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/jshint'''
} catch (err) {
echo "Unstable: ${err}"
}
}
}
Expand All @@ -28,10 +26,8 @@ pipeline {
"CSS Lint": {
node(label: 'docker') {
script {
try {
catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE') {
sh '''docker run -i --rm --name="$BUILD_TAG-csslint" -e GIT_SRC="https://github.com/eea/$GIT_NAME.git" -e GIT_NAME="$GIT_NAME" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/csslint'''
} catch (err) {
echo "Unstable: ${err}"
}
}
}
Expand All @@ -40,10 +36,8 @@ pipeline {
"PEP8": {
node(label: 'docker') {
script {
try {
catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE') {
sh '''docker run -i --rm --name="$BUILD_TAG-pep8" -e GIT_SRC="https://github.com/eea/$GIT_NAME.git" -e GIT_NAME="$GIT_NAME" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/pep8'''
} catch (err) {
echo "Unstable: ${err}"
}
}
}
Expand All @@ -52,10 +46,8 @@ pipeline {
"PyLint": {
node(label: 'docker') {
script {
try {
catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE') {
sh '''docker run -i --rm --name="$BUILD_TAG-pylint" -e GIT_SRC="https://github.com/eea/$GIT_NAME.git" -e GIT_NAME="$GIT_NAME" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/pylint'''
} catch (err) {
echo "Unstable: ${err}"
}
}
}
Expand Down Expand Up @@ -103,15 +95,11 @@ pipeline {
"WWW": {
node(label: 'docker') {
script {
try {
sh '''docker run -i --name="$BUILD_TAG-www" -e GIT_NAME="$GIT_NAME" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/www-devel /debug.sh coverage'''
sh '''mkdir -p xunit-reports; docker cp $BUILD_TAG-www:/plone/instance/parts/xmltestreport/testreports/. xunit-reports/'''
stash name: "xunit-reports", includes: "xunit-reports/*.xml"
sh '''docker cp $BUILD_TAG-www:/plone/instance/src/$GIT_NAME/coverage.xml coverage.xml'''
stash name: "coverage.xml", includes: "coverage.xml"
} finally {
sh '''docker rm -v $BUILD_TAG-www'''
}
sh '''docker run -i --name="$BUILD_TAG-www" -e GIT_NAME="$GIT_NAME" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/www-devel /debug.sh coverage'''
sh '''mkdir -p xunit-reports; docker cp $BUILD_TAG-www:/plone/instance/parts/xmltestreport/testreports/. xunit-reports/'''
stash name: "xunit-reports", includes: "xunit-reports/*.xml"
sh '''docker cp $BUILD_TAG-www:/plone/instance/src/$GIT_NAME/coverage.xml coverage.xml'''
stash name: "coverage.xml", includes: "coverage.xml"
junit 'xunit-reports/*.xml'
}
}
Expand All @@ -127,7 +115,30 @@ pipeline {
node(label: 'docker') {
sh '''docker run -i --rm --name="$BUILD_TAG-plone4" -e GIT_BRANCH="$BRANCH_NAME" -e ADDONS="$GIT_NAME[test]" -e DEVELOP="src/$GIT_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/plone-test:4 -v -vv -s $GIT_NAME'''
}
},

"Plone5 & Python2": {
node(label: 'docker') {
sh '''docker run -i --rm --name="$BUILD_TAG-plone5py2" -e GIT_BRANCH="$BRANCH_NAME" -e ADDONS="$GIT_NAME[test]" -e DEVELOP="src/$GIT_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/plone-test:5 -v -vv -s $GIT_NAME'''
}
},

"Plone5 & Python3": {
node(label: 'docker') {
catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE') {
sh '''docker run -i --rm --name="$BUILD_TAG-plone5py3" -e GIT_BRANCH="$BRANCH_NAME" -e ADDONS="$GIT_NAME[test]" -e DEVELOP="src/$GIT_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/plone-test:5-python3 -v -vv -s $GIT_NAME'''
}
}
},

"PloneSaaS": {
node(label: 'docker') {
catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE') {
sh '''docker run -i --rm --name="$BUILD_TAG-plonesaas" -e GIT_NAME="$GIT_NAME" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/plonesaas-devel /debug.sh bin/test --test-path /plone/instance/src/$GIT_NAME -v -vv -s $GIT_NAME'''
}
}
}

)
}
}
Expand Down
12 changes: 6 additions & 6 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include *.rst
recursive-include docs *
include *.py
include version.txt
global-exclude *py[co]

include *.md *.rst *.txt
graft docs
graft version.txt
global-exclude *pyc
global-exclude *~
global-exclude *.un~
global-include *.mo
11 changes: 9 additions & 2 deletions docs/HISTORY.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
Changelog
=========

3.5 - (2020-02-26)
--------------------------
* Feature: merged source code so it now works on both Python 2 and Python 3
[alecghica refs #110159]
* Feature: updated Jenkins pipeline
[alecghica refs #110159]

3.4 - (2019-01-28)
---------------------
--------------------------
* Jenkins: Add sonarqube step
[avoinea refs #101552]

3.3 - (2018-12-11)
---------------------
--------------------------
* Feature: when building the request from an endpoint that followed redirects
the query works fine now
[alecghica refs #100666]
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
keywords="Sparql Client",
author='European Environment Agency: IDM2 A-Team',
author_email='eea-edw-a-team-alerts@googlegroups.com',
long_description_content_type='text/x-rst',
url='https://github.com/eea/sparql-client',
license="MPL",
py_modules =['sparql'],
install_requires=[
'eventlet',
'eventlet', 'six'
],
extras_require={
'test': [
Expand Down
20 changes: 10 additions & 10 deletions sparql-client/tests/genquery.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@

import urllib,urllib2
import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error,six.moves.urllib.request,six.moves.urllib.error,six.moves.urllib.parse

statement = open("code.rq").read()
query = { 'query': statement,
'format':'xml' }

qs = urllib.urlencode(query)
print qs
url = "http://dbpedia.org/sparql?" + urllib.urlencode(query)
qs = six.moves.urllib.parse.urlencode(query)
print(qs)
url = "http://dbpedia.org/sparql?" + six.moves.urllib.parse.urlencode(query)

opener = urllib2.build_opener(urllib2.HTTPHandler)
urllib2.install_opener(opener)
req = urllib2.Request(url)
opener = six.moves.urllib.request.build_opener(six.moves.urllib.request.HTTPHandler)
six.moves.urllib.request.install_opener(opener)
req = six.moves.urllib.request.Request(url)
#req.add_header("Accept", "application/xml")

try:
conn = urllib2.urlopen(req, timeout=10)
conn = six.moves.urllib.request.urlopen(req, timeout=10)
except Exception:
conn = None

if not conn:
raise IOError, "Failure in open"
raise IOError("Failure in open")

data = conn.read()
conn.close()
print data
print(data)
7 changes: 4 additions & 3 deletions sparql-client/tests/testconversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sparql
import os.path
from mock import Mock, patch
from six.moves import map

_dirname = os.path.dirname(__file__)

Expand All @@ -25,11 +26,11 @@ def test_date(self):
u'foundingDate', u'timeexample'],
self.result.variables)

rows = map(sparql.unpack_row, self.result.fetchall())
rows = list(map(sparql.unpack_row, self.result.fetchall()))
row0 = rows[0]

self.assertEqual(type(row0[2]), datetime)
self.assertEqual(datetime(2009, 11, 02, 14, 31, 40), row0[2])
self.assertEqual(datetime(2009, 11, 0o2, 14, 31, 40), row0[2])

self.assertEqual(type(row0[3]), date)
self.assertEqual(date(1991, 8, 20), row0[3])
Expand All @@ -40,7 +41,7 @@ def test_date(self):
def test_decimal(self):
import decimal
self.assertEqual(self.result.variables[1], 'decimalData')
row0 = map(sparql.unpack_row, self.result.fetchall())[0]
row0 = list(map(sparql.unpack_row, self.result.fetchall()))[0]
decval = row0[1]
self.assertEqual(type(decval), decimal.Decimal)
self.assertEqual(str(decval), "123.456")
Expand Down
2 changes: 1 addition & 1 deletion sparql-client/tests/testhttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _get_response(self, opener, request, buf, timeout):

def _read_response(self, response, buf, timeout):
try:
from urlparse import parse_qs
from six.moves.urllib.parse import parse_qs
except ImportError:
from cgi import parse_qs
query = parse_qs(self.querystring).get('query', [''])[0]
Expand Down
8 changes: 5 additions & 3 deletions sparql-client/tests/testparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import os.path
from mock import patch
from xml.dom import pulldom
from six.moves import map
import six

def _open_datafile(name):
return open(os.path.join(os.path.dirname(__file__), name))
Expand All @@ -31,7 +33,7 @@ def test_unpack(self):
result = sparql._ResultsParser(resultfp)
self.assertEqual([u'eeaURI', u'gdpTotal', u'eeacode', u'nutscode', u'faocode', u'gdp', u'name'], result.variables)

rows = map(sparql.unpack_row, result.fetchall())
rows = list(map(sparql.unpack_row, result.fetchall()))
row0 = rows[0]
self.assertEqual(u"http://rdfdata.eionet.europa.eu/eea/countries/BE", row0[0])
# XSD_FAO_MILLION unpacked as string
Expand Down Expand Up @@ -93,7 +95,7 @@ def test_national(self):
row0 = rows[0]
self.assertEqual("http://aims.fao.org/aos/geopolitical.owl#Germany", str(row0[0]))
self.assertEqual(sparql.IRI(u"http://aims.fao.org/aos/geopolitical.owl#Germany"), row0[0])
self.assertEqual(u"Германия", unicode(row0[2]))
self.assertEqual(u"Германия", six.text_type(row0[2]))

def test_big_text(self):
# `xml.dom.pulldom` may return several text nodes within a single
Expand All @@ -117,7 +119,7 @@ def test_invalid_fetchone(self, mocked_element):
result = sparql._ResultsParser(resultfp)
setattr(result, 'events', result._fetchhead())
for row in result.fetchone():
print row
print(row)


if __name__ == '__main__':
Expand Down
Loading

0 comments on commit 3640252

Please sign in to comment.