Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supports Python3 #249

Merged
merged 133 commits into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from 132 commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
75a37f8
Split plugins
smotornyuk Dec 11, 2019
2ab242e
Update views
smotornyuk Dec 11, 2019
2803729
Update commands
smotornyuk Dec 11, 2019
e063522
Futurize
smotornyuk Dec 11, 2019
93951db
Add webassets.yml
smotornyuk Dec 11, 2019
27057e0
IClick support
smotornyuk Dec 13, 2019
a0fc527
pylons config
smotornyuk Jan 15, 2020
6060bc5
Fix encoding for gemini harvester
smotornyuk Jan 21, 2020
ca35e7a
Update encoding
smotornyuk Jan 21, 2020
1e6f689
Use 1.11 six api
smotornyuk Jan 21, 2020
de975a0
update requirements
Engerrs Jan 30, 2020
68a872a
remove future
smotornyuk Apr 14, 2020
a58510a
Remove builtins
smotornyuk Apr 14, 2020
e1abd5e
downgrade owslib
smotornyuk Apr 14, 2020
03272a9
Update tests
smotornyuk Apr 14, 2020
6327402
owslib==0.18.0
smotornyuk Apr 14, 2020
f7dc2bf
Update tests
smotornyuk May 3, 2020
2420d62
Fix import for nose tests
smotornyuk May 5, 2020
e84430a
Install setuptools
smotornyuk May 5, 2020
123fc5a
Backport pytests
smotornyuk May 6, 2020
411e20d
Update travis scripts
smotornyuk May 6, 2020
4b7cd9f
rename clean_db fixture
smotornyuk May 6, 2020
bc8cdc3
add pycsw
smotornyuk May 6, 2020
8ea5312
changies in db init
smotornyuk May 6, 2020
aab68f8
Merge remote-tracking branch 'origin/master' into py3
smotornyuk May 18, 2020
920c725
WIP: ci test
smellman Jan 6, 2021
e798694
WIP: github actions ci: fixes solr/schema.xml path
smellman Jan 6, 2021
81f8685
WIP: github actions ci: fixes solr conf path
smellman Jan 6, 2021
fbf948d
WIP: github actions ci: use test-core.ini and copy configurations fro…
smellman Jan 6, 2021
ac46868
WIP: github actions ci: setup spatial tables
smellman Jan 6, 2021
a3f8b97
WIP: github actions ci: remove create extension
smellman Jan 6, 2021
db9ed4a
WIP: github actions ci: set table to alter view/table
smellman Jan 6, 2021
078c184
WIP: github actions ci: install postgis to ckan_test database
smellman Jan 6, 2021
f111016
WIP: reset_db will fail to drop table spatial_ref_sys, so use drop ex…
smellman Jan 6, 2021
44e9ec0
WIP: close all session before drop postgis extension
smellman Jan 6, 2021
50311ac
WIP: added cascade option
smellman Jan 6, 2021
f8e3b70
WIP: test: setup only create extension
smellman Jan 6, 2021
cfd0ff7
WIP: use pass_spatial_ref_sys
smellman Jan 6, 2021
2e11aee
WIP: ckan_default become spatial_ref_sys owner
smellman Jan 6, 2021
3d82e76
WIP: downgrade to postgis 2.5
smellman Jan 6, 2021
c46936a
WIP: drop table spatial_ref_sys when drop extension postgis
smellman Jan 6, 2021
6e57837
WIP: test: remove spatial_ref_sys from metadata.tables
smellman Jan 6, 2021
468ed05
WIP: test: added debug comment
smellman Jan 6, 2021
e9af0c8
WIP: show all messages
smellman Jan 6, 2021
4681706
WIP: remove spatial_ref_sys table in ckan's clean_db
smellman Jan 6, 2021
b0967a1
WIP: added --reset-db option
smellman Jan 6, 2021
ddbc64f
WIP: test: --reset-db option
smellman Jan 6, 2021
32244f6
WIP: remove --reset-db option, use test-github-actions.ini for db init
smellman Jan 6, 2021
55df859
WIP: test: added ckan_harvester and test*harvester
smellman Jan 6, 2021
0820b19
WIP: test: added with_plugins
smellman Jan 6, 2021
eece0a8
WIP: test: remove package_extent before spatial_db_setup()
smellman Jan 7, 2021
14d98bc
WIP: test: use {} instead of set()
smellman Jan 7, 2021
26286fa
WIP: test: use clean_db instead of spatial_clean_db
smellman Jan 7, 2021
4cca582
WIP: test: use harvest_setup
smellman Jan 7, 2021
c0626cc
WIP: test: test_api use harvest_setup
smellman Jan 7, 2021
d7a2b7e
WIP: test: added harvest_setup fixture
smellman Jan 7, 2021
6c3c9f4
WIP: test: added spatial_setup fixture
smellman Jan 7, 2021
1663e93
WIP: test: remove package_extent issue
smellman Jan 7, 2021
bf29fa0
WIP: test: revert package_extent issue
smellman Jan 7, 2021
68acc99
WIP: test: extend_existing flag
smellman Jan 7, 2021
84d06e0
WIP: use ckan master
smellman Jan 7, 2021
12eb8c0
WIP: drop index for package_extent
smellman Jan 7, 2021
77558ec
WIP: force remove index for package_extent
smellman Jan 7, 2021
23a36d1
WIP: added if exists option, added spatial_setup fixture to all
smellman Jan 7, 2021
4224a5c
WIP: start server in ci
smellman Jan 7, 2021
dc5bbba
WIP: fix typo
smellman Jan 7, 2021
eea232a
WIP: build frontend
smellman Jan 7, 2021
6d5b276
WIP: use master branch
smellman Jan 7, 2021
ff9dc44
WIP: create/drop extension postgis in ci
smellman Jan 7, 2021
cdb027a
WIP: test: enable to remove postgis extension
smellman Jan 7, 2021
787cbb5
WIP: test: create postgis extension with ckan_default user
smellman Jan 7, 2021
b518cfa
WIP: test: setup postgis in test fixture
smellman Jan 7, 2021
cdee92f
WIP: test: create extension postgis via ckan_default user
smellman Jan 7, 2021
9ddce2f
WIP: fix typo
smellman Jan 7, 2021
1046309
WIP: test: ckan_default become superuser
smellman Jan 7, 2021
9f45d31
WIP: create postgis extension before check postgis version
smellman Jan 7, 2021
075b6d6
WIP: drop import sql
smellman Jan 7, 2021
a1ba3fd
WIP: drop package_extent table in clean up postgis
smellman Jan 8, 2021
b0a3290
WIP: added fixture each test
smellman Jan 14, 2021
4ff78e0
WIP: remove clean_db
smellman Jan 14, 2021
3477ecc
WIP: call initial_data in each function(autouse=True fixture doesn't …
smellman Jan 14, 2021
f623dfb
WIP: use asset instead of resource
smellman Jan 14, 2021
90bea3c
remove travis ci settings
smellman Jan 14, 2021
d75beac
WIP: rewrite ci
smellman Jan 15, 2021
0fb40c4
WIP: fixes Syntax Error
smellman Jan 15, 2021
37cc1d2
WIP: fixes user and host
smellman Jan 15, 2021
853842f
WIP: install via pip
smellman Jan 15, 2021
02f5730
WIP: install geos
smellman Jan 15, 2021
6aae281
WIP: added proj
smellman Jan 15, 2021
787dd59
WIP: added proj-util
smellman Jan 15, 2021
09c766f
WIP: downgrade pyproj
smellman Jan 15, 2021
849c0b8
WIP: added gcc, libxml2 and libxlst
smellman Jan 15, 2021
071d29a
WIP: downgrade pyproj 2.2.2
smellman Jan 15, 2021
e97f103
WIP: install python-dev or python3-dev
smellman Jan 15, 2021
75e7f40
WIP: install python2-dev
smellman Jan 15, 2021
578592a
WIP: install packages in global
smellman Jan 15, 2021
1b627d2
WIP: install geos-dev and proj-dev
smellman Jan 15, 2021
4ae6c4e
WIP: fixes database name and user
smellman Jan 15, 2021
9fe84f2
WIP: fix typo
smellman Jan 15, 2021
d0735a9
WIP: fixes missing python3-dev install, split pip-requirements.txt fo…
smellman Jan 15, 2021
60f5cf1
WIP: setup postgis
smellman Jan 15, 2021
e690b78
WIP: remove some option from pytest
smellman Jan 15, 2021
856331e
WIP: remove --ckan-ini option
smellman Jan 15, 2021
a4cb1ad
WIP: test: remove ckan_setup
smellman Jan 15, 2021
a9bb23c
WIP: downgrade postgis
smellman Jan 15, 2021
20e7598
WIP: supports ckan 2.8
smellman Jan 18, 2021
0b40509
WIP: remove package_*_return_url
smellman Jan 18, 2021
b0ed33e
WIP: remove with_plugins fixture
smellman Jan 18, 2021
d919c04
WIP: added test for ci
smellman Jan 18, 2021
75cf94f
WIP: fixes search_backend to postgis
smellman Jan 18, 2021
4448fed
WIP: set fixture each functions
smellman Jan 18, 2021
706c47b
WIP: use postgis 10-2.5 image
smellman Jan 18, 2021
3f38e29
Merge branch 'dev-py3' of github.com:smellman/ckanext-spatial into de…
smellman Jan 18, 2021
3364ca0
WIP: don't drop idx_package_extent_the_geom
smellman Jan 18, 2021
1e8b223
WIP: test: copy error function to last test
smellman Jan 18, 2021
56b4290
WIP: don't set alter view and table, remove test code
smellman Jan 18, 2021
7d3dbfc
WIP: debug print
smellman Jan 18, 2021
487cbc8
WIP: debug print
smellman Jan 18, 2021
01ad817
WIP: debug print
smellman Jan 18, 2021
5b744cb
WIP: debug print
smellman Jan 18, 2021
2a8da19
WIP: debug print
smellman Jan 18, 2021
1d7d913
WIP: debug print
smellman Jan 18, 2021
93f7502
WIP: don't remove metadata
smellman Jan 18, 2021
36d0d9b
WIP: debug
smellman Jan 18, 2021
6617d21
WIP: postgis 10-3.1
smellman Jan 18, 2021
43140c8
WIP: test: skip db setup
smellman Jan 18, 2021
4f47dda
WIP: test: skip db setup
smellman Jan 18, 2021
2477721
WIP: fixes warning
smellman Jan 19, 2021
5bdd481
WIP: remove ""
smellman Jan 19, 2021
8821118
WIP: remove print debug and fixes test
smellman Jan 19, 2021
e57edfd
remove unused ini
smellman Jan 19, 2021
2934317
added note for github action and added failback code
smellman Jan 19, 2021
dd42aa8
remove unused print debug
smellman May 25, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: ckanext-spatial ci
on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.6'
- name: Install requirements
run: pip install flake8 pycodestyle
- name: Check syntax
run: flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics --exclude ckan
test:
needs: lint
strategy:
matrix:
ckan-version: [2.9, 2.9-py2, 2.8, 2.7]
fail-fast: false

name: CKAN ${{ matrix.ckan-version }}
runs-on: ubuntu-latest
container:
image: openknowledge/ckan-dev:${{ matrix.ckan-version }}
services:
solr:
image: ckan/ckan-solr-dev:${{ matrix.ckan-version }}
postgres:
image: postgis/postgis:10-3.1
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: redis:3
env:
CKAN_SQLALCHEMY_URL: postgresql://ckan_default:pass@postgres/ckan_test
CKAN_DATASTORE_WRITE_URL: postgresql://datastore_write:pass@postgres/datastore_test
CKAN_DATASTORE_READ_URL: postgresql://datastore_read:pass@postgres/datastore_test
CKAN_SOLR_URL: http://solr:8983/solr/ckan
CKAN_REDIS_URL: redis://redis:6379/1
PGPASSWORD: postgres

steps:
- uses: actions/checkout@v2
- name: Create Database
run: |
psql --host=postgres --username=postgres --command="CREATE USER ckan_default WITH PASSWORD 'pass' NOSUPERUSER NOCREATEDB NOCREATEROLE;"
createdb --encoding=utf-8 --host=postgres --username=postgres --owner=ckan_default ckan_test
psql --host=postgres --username=postgres --command="CREATE USER datastore_write WITH PASSWORD 'pass' NOSUPERUSER NOCREATEDB NOCREATEROLE;"
psql --host=postgres --username=postgres --command="CREATE USER datastore_read WITH PASSWORD 'pass' NOSUPERUSER NOCREATEDB NOCREATEROLE;"
createdb --encoding=utf-8 --host=postgres --username=postgres --owner=datastore_write datastore_test
- name: Install harvester
run: |
git clone https://github.com/ckan/ckanext-harvest
cd ckanext-harvest
pip install -r pip-requirements.txt
pip install -r dev-requirements.txt
pip install -e .
- name: Install dependency (common)
run: |
apk add --no-cache \
geos \
geos-dev \
proj-util \
proj-dev \
libxml2 \
libxslt \
gcc \
libxml2-dev \
libxslt-dev
- name: Install dependency (python2)
if: ${{ matrix.ckan-version != '2.9' }}
run: |
apk add --no-cache \
python2-dev
- name: Install dependency (python3)
if: ${{ matrix.ckan-version == '2.9' }}
run: |
apk add --no-cache \
python3-dev
- name: Install requirements (python2)
if: ${{ matrix.ckan-version != '2.9' }}
run: |
pip install -r pip-requirements.txt
- name: Install requirements (python3)
if: ${{ matrix.ckan-version == '2.9' }}
run: |
pip install -r pip3-requirements.txt
- name: Install requirements
run: |
pip install -e .
# Replace default path to CKAN core config file with the one on the container
sed -i -e 's/use = config:.*/use = config:\/srv\/app\/src\/ckan\/test-core.ini/' test.ini
- name: setup postgis
run: |
psql --host=postgres --username=postgres -d ckan_test --command="ALTER ROLE ckan_default WITH superuser;"
psql --host=postgres --username=postgres -d ckan_test --command="CREATE EXTENSION postgis;"
- name: Run tests
run: pytest --ckan-ini=test.ini ckanext/spatial/tests
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

16 changes: 8 additions & 8 deletions bin/ckan_pycsw.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def load(pycsw_config, ckan_url):
response = requests.get(url)
listing = response.json()
if not isinstance(listing, dict):
raise RuntimeError, 'Wrong API response: %s' % listing
raise RuntimeError('Wrong API response: %s' % listing)
results = listing.get('results')
if not results:
break
Expand Down Expand Up @@ -115,7 +115,7 @@ def load(pycsw_config, ckan_url):
ckan_id=ckan_id).delete()
log.info('Deleted %s' % ckan_id)
repo.session.commit()
except Exception, err:
except Exception as err:
repo.session.rollback()
raise

Expand All @@ -128,7 +128,7 @@ def load(pycsw_config, ckan_url):
try:
repo.insert(record, 'local', util.get_today_and_now())
log.info('Inserted %s' % ckan_id)
except Exception, err:
except Exception as err:
log.error('ERROR: not inserted %s Error:%s' % (ckan_id, err))

for ckan_id in changed:
Expand All @@ -145,9 +145,9 @@ def load(pycsw_config, ckan_url):
ckan_id=ckan_id).update(update_dict)
repo.session.commit()
log.info('Changed %s' % ckan_id)
except Exception, err:
except Exception as err:
repo.session.rollback()
raise RuntimeError, 'ERROR: %s' % str(err)
raise RuntimeError('ERROR: %s' % str(err))


def clear(pycsw_config):
Expand All @@ -174,13 +174,13 @@ def get_record(context, repo, ckan_url, ckan_id, ckan_info):

try:
xml = etree.parse(io.BytesIO(response.content))
except Exception, err:
except Exception as err:
log.error('Could not pass xml doc from %s, Error: %s' % (ckan_id, err))
return

try:
record = metadata.parse_record(context, xml, repo)[0]
except Exception, err:
except Exception as err:
log.error('Could not extract metadata from %s, Error: %s' % (ckan_id, err))
return

Expand Down Expand Up @@ -270,5 +270,5 @@ def _load_config(file_path):
elif arg.command == 'clear':
clear(pycsw_config)
else:
print 'Unknown command {0}'.format(arg.command)
print('Unknown command {0}'.format(arg.command))
sys.exit(1)
78 changes: 0 additions & 78 deletions bin/travis-build.bash

This file was deleted.

3 changes: 0 additions & 3 deletions bin/travis-run.sh

This file was deleted.

53 changes: 53 additions & 0 deletions ckanext/spatial/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# encoding: utf-8
import click
import logging

import ckanext.spatial.util as util


log = logging.getLogger(__name__)

def get_commands():
return [
spatial,
spatial_validation
]


@click.group(u"spatial-validation", short_help=u"Validation commands")
def spatial_validation():
pass


@spatial_validation.command()
@click.argument('pkg', required=False)
def report(pkg):
return util.report(pkg)


@spatial_validation.command('report-csv')
@click.argument('filepath')
def report_csv(filepath):
return util.report_csv(filepath)


@spatial_validation.command('file')
@click.argument('filepath')
def validate_file(filepath):
return util.validate_file(filepath)


@click.group(short_help=u"Performs spatially related operations.")
def spatial():
pass


@spatial.command()
@click.argument('srid', required=False)
def initdb(srid):
return util.initdb(srid)


@spatial.command('extents')
def update_extents():
return util.update_extents()
3 changes: 2 additions & 1 deletion ckanext/spatial/commands/csw.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import sys
import logging

Expand Down Expand Up @@ -63,4 +64,4 @@ def command(self):
elif cmd == 'clear':
ckan_pycsw.clear(config)
else:
print 'Command %s not recognized' % cmd
print('Command %s not recognized' % cmd)
Loading