Skip to content

Commit

Permalink
Copy CKAN extension boiler-plate from core ckan template: paster --pl…
Browse files Browse the repository at this point in the history
…ugin=ckan create -t ckanext ckanext-archiver
  • Loading branch information
David Read committed Oct 27, 2015
1 parent c3a4b81 commit ebca07d
Show file tree
Hide file tree
Showing 12 changed files with 300 additions and 59 deletions.
5 changes: 5 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[report]
omit =
*/site-packages/*
*/python?.?/*
ckan/*
58 changes: 51 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,52 @@
*.pyc
*.egg-info
build
*.egg
.DS_Store
*.swp
# archiver settings should not be checked in - only its template
ckanext/archiver/settings.py
*~

.DS_Store
# vim
*.sw?
# emacs
*~

.ropeproject
node_modules
bower_components

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
sdist/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Sphinx documentation
docs/_build/

10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: python
python:
- "2.7"
env: PGVERSION=9.1
install:
- bash bin/travis-build.bash
- pip install coveralls
script: sh bin/travis-run.sh
after_success:
- coveralls
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 Open Knowledge & Crown Copyright

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include README.rst
recursive-include ckanext/archiver *.html *.json *.js *.less *.css
56 changes: 40 additions & 16 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
CKAN Archiver Extension
=======================
.. You should enable this project on travis-ci.org and coveralls.io to make
these badges work. The necessary Travis and Coverage config files have been
generated for you.
**Status:** Production
.. image:: https://travis-ci.org/datagovuk/ckanext-archiver.svg?branch=master
:target: https://travis-ci.org/datagovuk/ckanext-archiver

**CKAN Version:** release-1.7.1-dgu
.. image:: https://pypip.in/py_versions/ckanext-archiver/badge.svg
:target: https://pypi.python.org/pypi/ckanext-archiver/
:alt: Supported Python versions

.. image:: https://pypip.in/status/ckanext-archiver/badge.svg
:target: https://pypi.python.org/pypi/ckanext-archiver/
:alt: Development Status

.. image:: https://pypip.in/license/ckanext-archiver/badge.svg
:target: https://pypi.python.org/pypi/ckanext-archiver/
:alt: License

=============
ckanext-archiver
=============

Overview
--------
Expand All @@ -25,21 +40,32 @@ This means that the 'bulk' queue can happily run slowly, chugging through the do
Installation
------------

Install the extension source as usual, e.g. (from an activated virtualenv)::
To install ckanext-archiver:

1. Activate your CKAN virtual environment, for example::

. /usr/lib/ckan/default/bin/activate

$ pip install -e git+http://github.com/datagovuk/ckanext-archiver.git#egg=ckanext-archiver
2. Install the ckanext-archiver Python package into your virtual environment::

Or (primarily for developers) download the source, then from the ckanext-archiver directory run::
pip install -e git+http://github.com/datagovuk/ckanext-archiver.git#egg=ckanext-archiver

$ pip install -e ./
3. Now create the database tables::

Whichever way you install the source, you now must create the database tables::
paster --plugin=ckanext-archiver archiver init --config=production.ini

$ paster --plugin=ckanext-archiver archiver init --config=ckan.ini
4. Add ``archiver`` to the ``ckan.plugins`` setting in your CKAN
config file (by default the config file is located at
``/etc/ckan/default/production.ini``).

5. Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu::

Configuration
-------------
sudo service apache2 reload



Config settings
---------------

1. Enabling Archiver to listen to resource changes

Expand Down Expand Up @@ -131,8 +157,6 @@ The Archiver can be used in two ways:
Testing
-------

Tests should be run from the CKAN root directory (not the extension root).

::
To run the tests, from the CKAN root directory (not the extension root) do::

(pyenv)~/pyenv/src/ckan$ nosetests --ckan ../ckanext-archiver/tests/ --with-pylons=../ckanext-archiver/test.ini
(pyenv)~/pyenv/src/ckan$ nosetests --ckan ../ckanext-archiver/tests/ --with-pylons=../ckanext-archiver/test-core.ini
38 changes: 38 additions & 0 deletions bin/travis-build.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
set -e

echo "This is travis-build.bash..."

echo "Installing the packages that CKAN requires..."
sudo apt-get update -qq
sudo apt-get install postgresql-$PGVERSION solr-jetty libcommons-fileupload-java:amd64=1.2.2-1

echo "Installing CKAN and its Python dependencies..."
git clone https://github.com/ckan/ckan
cd ckan
export latest_ckan_release_branch=`git branch --all | grep remotes/origin/release-v | sort -r | sed 's/remotes\/origin\///g' | head -n 1`
echo "CKAN branch: $latest_ckan_release_branch"
git checkout $latest_ckan_release_branch
python setup.py develop
pip install -r requirements.txt --allow-all-external
pip install -r dev-requirements.txt --allow-all-external
cd -

echo "Creating the PostgreSQL user and database..."
sudo -u postgres psql -c "CREATE USER ckan_default WITH PASSWORD 'pass';"
sudo -u postgres psql -c 'CREATE DATABASE ckan_test WITH OWNER ckan_default;'

echo "Initialising the database..."
cd ckan
paster db init -c test-core.ini
cd -

echo "Installing ckanext-ckanext-archiver and its requirements..."
python setup.py develop
pip install -r dev-requirements.txt

echo "Moving test.ini into a subdir..."
mkdir subdir
mv test.ini subdir

echo "travis-build.bash is done."
6 changes: 6 additions & 0 deletions bin/travis-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh -e

echo "NO_START=0\nJETTY_HOST=127.0.0.1\nJETTY_PORT=8983\nJAVA_HOME=$JAVA_HOME" | sudo tee /etc/default/jetty
sudo cp ckan/ckan/config/solr/schema.xml /etc/solr/conf/schema.xml
sudo service jetty restart
nosetests --nologcapture --with-pylons=subdir/test.ini --with-coverage --cover-package=ckanext.archiver --cover-inclusive --cover-erase --cover-tests
2 changes: 2 additions & 0 deletions ckanext/archiver/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ def _save(status_id, exception, resource, url_redirected_to=None,
_save(Status.by_text('Archived successfully'), '', resource,
download_result['url_redirected_to'], download_result, archive_result)
# The return value is only used by tests. Serialized for Celery.
print download_result
print archive_result
return json.dumps(dict(download_result, **archive_result))


Expand Down
21 changes: 21 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[extract_messages]
keywords = translate isPlural
add_comments = TRANSLATORS:
output_file = i18n/ckanext-archiver.pot
width = 80

[init_catalog]
domain = ckanext-archiver
input_file = i18n/ckanext-archiver.pot
output_dir = i18n

[update_catalog]
domain = ckanext-archiver
input_file = i18n/ckanext-archiver.pot
output_dir = i18n
previous = true

[compile_catalog]
domain = ckanext-archiver
directory = i18n
statistics = true
Loading

0 comments on commit ebca07d

Please sign in to comment.