Skip to content

Commit

Permalink
Merge pull request #35 from qld-gov-au/develop
Browse files Browse the repository at this point in the history
Develop to master
  • Loading branch information
ThrawnCA authored Nov 1, 2021
2 parents 0b1b9c5 + de98f8c commit 450c8ab
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
exclude =
ckan
scripts
.git

# Extended output format.
format = pylint
Expand Down
10 changes: 5 additions & 5 deletions ckanext/xloader/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@ def xloader_data_into_datastore(input):
job_dict['status'] = 'complete'
db.mark_job_as_completed(job_id, job_dict)
except JobError as e:
db.mark_job_as_errored(job_id, str(e))
db.mark_job_as_errored(job_id, six.text_type(e))
job_dict['status'] = 'error'
job_dict['error'] = str(e)
job_dict['error'] = six.text_type(e)
log = logging.getLogger(__name__)
log.error('xloader error: {0}, {1}'.format(e, traceback.format_exc()))
errored = True
except Exception as e:
db.mark_job_as_errored(
job_id, traceback.format_tb(sys.exc_info()[2])[-1] + repr(e))
job_dict['status'] = 'error'
job_dict['error'] = str(e)
job_dict['error'] = six.text_type(e)
log = logging.getLogger(__name__)
log.error('xloader error: {0}, {1}'.format(e, traceback.format_exc()))
errored = True
Expand Down Expand Up @@ -317,9 +317,9 @@ def _download_resource_data(resource, data, api_key, logger):
DOWNLOAD_TIMEOUT))
except requests.exceptions.RequestException as e:
try:
err_message = str(e.reason)
err_message = six.text_type(e.reason)
except AttributeError:
err_message = str(e)
err_message = six.text_type(e)
logger.warning('URL error: %s', err_message)
raise HTTPError(
message=err_message, status_code=None,
Expand Down
6 changes: 5 additions & 1 deletion ckanext/xloader/schema.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# encoding: utf-8

import six

import ckan.plugins as p
import ckanext.datastore.logic.schema as dsschema

Expand All @@ -16,7 +20,7 @@
if p.toolkit.check_ckan_version('2.9'):
unicode_safe = get_validator('unicode_safe')
else:
unicode_safe = str
unicode_safe = six.text_type


def xloader_submit_schema():
Expand Down
9 changes: 5 additions & 4 deletions ckanext/xloader/tests/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest
import sqlalchemy.orm as orm
import datetime
import six
from decimal import Decimal

from ckan.tests import factories
Expand Down Expand Up @@ -779,10 +780,10 @@ def test_kml(self):
mimetype="text/csv",
logger=PrintLogger(),
)
assert "Error with field definition" in str(exception.value)
assert "Error with field definition" in six.text_type(exception.value)
assert (
'"<?xml version="1.0" encoding="utf-8" ?>" is not a valid field name'
in str(exception.value)
in six.text_type(exception.value)
)

def test_geojson(self):
Expand All @@ -796,10 +797,10 @@ def test_geojson(self):
mimetype="text/csv",
logger=PrintLogger(),
)
assert "Error with field definition" in str(exception.value)
assert "Error with field definition" in six.text_type(exception.value)
assert (
'"{"type":"FeatureCollection"" is not a valid field name'
in str(exception.value)
in six.text_type(exception.value)
)

def test_shapefile_zip(self):
Expand Down
5 changes: 4 additions & 1 deletion ckanext/xloader/tests/test_plugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# encoding: utf-8

import datetime
import pytest
import mock
import six
from ckan.tests import helpers, factories
from ckan.logic import _actions

Expand Down Expand Up @@ -57,7 +60,7 @@ def _pending_task(self, resource_id):
"entity_id": resource_id,
"entity_type": "resource",
"task_type": "xloader",
"last_updated": str(datetime.datetime.utcnow()),
"last_updated": six.text_type(datetime.datetime.utcnow()),
"state": "pending",
"key": "xloader",
"value": "{}",
Expand Down

0 comments on commit 450c8ab

Please sign in to comment.