Commit ab0c08c8 authored by endk-mirror-svc's avatar endk-mirror-svc

Initial Commit

parents
[report]
omit =
*/site-packages/*
*/python?.?/*
ckan/*
\ No newline at end of file
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# 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
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
language: python
sudo: required
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
This diff is collapsed.
include README.rst
include LICENSE
include requirements.txt
recursive-include ckanext/systeminfo *.html *.json *.js *.less *.css *.mo
\ No newline at end of file
.. 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.
.. image:: https://travis-ci.org/keitaroinc/ckanext-systeminfo.svg?branch=master
:target: https://travis-ci.org/keitaroinc/ckanext-systeminfo
.. image:: https://coveralls.io/repos/keitaroinc/ckanext-systeminfo/badge.svg
:target: https://coveralls.io/r/keitaroinc/ckanext-systeminfo
.. image:: https://pypip.in/download/ckanext-systeminfo/badge.svg
:target: https://pypi.python.org/pypi//ckanext-systeminfo/
:alt: Downloads
.. image:: https://pypip.in/version/ckanext-systeminfo/badge.svg
:target: https://pypi.python.org/pypi/ckanext-systeminfo/
:alt: Latest Version
.. image:: https://pypip.in/py_versions/ckanext-systeminfo/badge.svg
:target: https://pypi.python.org/pypi/ckanext-systeminfo/
:alt: Supported Python versions
.. image:: https://pypip.in/status/ckanext-systeminfo/badge.svg
:target: https://pypi.python.org/pypi/ckanext-systeminfo/
:alt: Development Status
.. image:: https://pypip.in/license/ckanext-systeminfo/badge.svg
:target: https://pypi.python.org/pypi/ckanext-systeminfo/
:alt: License
=============
ckanext-systeminfo
=============
.. Put a description of your extension here:
What does it do? What features does it have?
Consider including some screenshots or embedding a video!
------------
Requirements
------------
For example, you might want to mention here which versions of CKAN this
extension works with.
------------
Installation
------------
.. Add any additional install steps to the list below.
For example installing any non-Python dependencies or adding any required
config settings.
To install ckanext-systeminfo:
1. Activate your CKAN virtual environment, for example::
. /usr/lib/ckan/default/bin/activate
2. Install the ckanext-systeminfo Python package into your virtual environment::
pip install ckanext-systeminfo
3. Add ``systeminfo`` to the ``ckan.plugins`` setting in your CKAN
config file (by default the config file is located at
``/etc/ckan/default/production.ini``).
4. Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu::
sudo service apache2 reload
---------------
Config Settings
---------------
Document any optional config settings here. For example::
# The minimum number of hours to wait before re-checking a resource
# (optional, default: 24).
ckanext.systeminfo.some_setting = some_default_value
------------------------
Development Installation
------------------------
To install ckanext-systeminfo for development, activate your CKAN virtualenv and
do::
git clone https://github.com/keitaroinc/ckanext-systeminfo.git
cd ckanext-systeminfo
python setup.py develop
pip install -r dev-requirements.txt
-----------------
Running the Tests
-----------------
To run the tests, do::
nosetests --nologcapture --with-pylons=test.ini
To run the tests and produce a coverage report, first make sure you have
coverage installed in your virtualenv (``pip install coverage``) then run::
nosetests --nologcapture --with-pylons=test.ini --with-coverage --cover-package=ckanext.systeminfo --cover-inclusive --cover-erase --cover-tests
---------------------------------
Registering ckanext-systeminfo on PyPI
---------------------------------
ckanext-systeminfo should be availabe on PyPI as
https://pypi.python.org/pypi/ckanext-systeminfo. If that link doesn't work, then
you can register the project on PyPI for the first time by following these
steps:
1. Create a source distribution of the project::
python setup.py sdist
2. Register the project::
python setup.py register
3. Upload the source distribution to PyPI::
python setup.py sdist upload
4. Tag the first release of the project on GitHub with the version number from
the ``setup.py`` file. For example if the version number in ``setup.py`` is
0.0.1 then do::
git tag 0.0.1
git push --tags
----------------------------------------
Releasing a New Version of ckanext-systeminfo
----------------------------------------
ckanext-systeminfo is availabe on PyPI as https://pypi.python.org/pypi/ckanext-systeminfo.
To publish a new version to PyPI follow these steps:
1. Update the version number in the ``setup.py`` file.
See `PEP 440 <http://legacy.python.org/dev/peps/pep-0440/#public-version-identifiers>`_
for how to choose version numbers.
2. Create a source distribution of the new version::
python setup.py sdist
3. Upload the source distribution to PyPI::
python setup.py sdist upload
4. Tag the new release of the project on GitHub with the version number from
the ``setup.py`` file. For example if the version number in ``setup.py`` is
0.0.2 then do::
git tag 0.0.2
git push --tags
#!/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 "SOLR config..."
# Solr is multicore for tests on ckan master, but it's easier to run tests on
# Travis single-core. See https://github.com/ckan/ckan/issues/2972
sed -i -e 's/solr_url.*/solr_url = http:\/\/127.0.0.1:8983\/solr/' ckan/test-core.ini
echo "Initialising the database..."
cd ckan
paster db init -c test-core.ini
cd -
echo "Installing ckanext-systeminfo 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."
\ No newline at end of file
#!/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.systeminfo --cover-inclusive --cover-erase --cover-tests
\ No newline at end of file
# encoding: utf-8
# this is a namespace package
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
# -*- coding: utf-8 -
import os
import logging
import git
log = logging.getLogger(__name__)
def get_info():
root = os.path.abspath(os.path.join(
os.path.dirname(__file__),
'../../../'
))
extensions = []
for _, __, ___ in os.walk(root):
for dir in __:
if dir.startswith('ckanext'):
extensions.append(os.path.join(root, dir))
break
result = {}
for ext in extensions:
ext_name = ext.split('/')[-1]
if ext_name in result.keys():
continue
try:
repo = git.Repo(ext)
except:
# Check if submodule
try:
sub = git.Submodule(ext)
branch, tag = None, None
commit = sub.parent_commit
result.update({ext_name: {
'branch': branch,
'commit': commit,
'tag': tag
}})
continue
except:
continue
branch, commit, tag = None, repo.head.commit.hexsha, None
try:
branch = repo.active_branch.name
except TypeError:
pass
for t in repo.tags:
if t is None:
continue
if t.commit.hexsha == commit:
tag = t.name
result.update({ext_name: {
'branch': branch,
'commit': commit,
'tag': tag
}})
return result
# -*- coding: utf-8 -
import logging
import ckanext.systeminfo.helpers as h
log = logging.getLogger(__name__)
import ckan.plugins as p
import ckan.plugins.toolkit as t
class SysteminfoPlugin(p.SingletonPlugin):
p.implements(p.IConfigurer)
p.implements(p.ITemplateHelpers)
# IConfigurer
def update_config(self, config_):
t.add_template_directory(config_, 'templates')
t.add_public_directory(config_, 'public')
t.add_resource('fanstatic', 'systeminfo')
# ITemplateHelpers
def get_helpers(self):
return {
'show_system_info': h.get_info,
}
{% ckan_extends %}
{% block primary_content %}
{{super()}}
{% if h.check_access('organization_create', {}) %}
<h2>{{_('Active extensions')}}</h2>
<p>{{_('Add description text')}}</p>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>{{_('Extension')}}</th>
<th>{{_('Branch')}}</th>
<th>{{_('Commit')}}</th>
<th>{{_('Tag')}}</th>
</tr>
</thead>
<tbody>
{% set extensions = h.show_system_info() %}
{% for key, val in extensions.items() %}
<tr>
<td>{{key}}</td>
<td>{{val.branch}}</td>
<td>{{val.commit}}</td>
<td>{{val.tag or ''}}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% endblock %}
"""Tests for plugin.py."""
import ckanext.systeminfo.plugin as plugin
def test_plugin():
pass
\ No newline at end of file
GitPython==2.1.3
\ No newline at end of file
[extract_messages]
keywords = translate isPlural
add_comments = TRANSLATORS:
output_file = i18n/ckanext-systeminfo.pot
width = 80
[init_catalog]
domain = ckanext-systeminfo
input_file = i18n/ckanext-systeminfo.pot
output_dir = i18n
[update_catalog]
domain = ckanext-systeminfo
input_file = i18n/ckanext-systeminfo.pot
output_dir = i18n
previous = true
[compile_catalog]
domain = ckanext-systeminfo
directory = i18n
statistics = true
\ No newline at end of file
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages # Always prefer setuptools over distutils
from codecs import open # To use a consistent encoding
from os import path
here = path.abspath(path.dirname(__file__))
# Get the long description from the relevant file
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
long_description = f.read()
setup(
name='''ckanext-systeminfo''',
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# http://packaging.python.org/en/latest/tutorial.html#version
version='0.0.1',
description='''Show all active extensions in the about page''',
long_description=long_description,
# The project's main homepage.
url='https://github.com/keitaroinc/ckanext-systeminfo',
# Author details
author='''Keitaro Inc''',
author_email='''info@keitaro.com''',
# Choose your license
license='AGPL',
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
'Development Status :: 4 - Beta',
# Pick your license as you wish (should match "license" above)
'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python :: 2.7',
],
# What does your project relate to?
keywords='''CKAN System info''',
# You can just specify the packages manually here if your project is
# simple. Or you can use find_packages().
packages=find_packages(exclude=['contrib', 'docs', 'tests*']),
namespace_packages=['ckanext'],
install_requires=[
# CKAN extensions should not list dependencies here, but in a separate
# ``requirements.txt`` file.
#
# http://docs.ckan.org/en/latest/extensions/best-practices.html#add-third-party-libraries-to-requirements-txt
],
# If there are data files included in your packages that need to be
# installed, specify them here. If using Python 2.6 or less, then these
# have to be included in MANIFEST.in as well.
include_package_data=True,
package_data={
},
# Although 'package_data' is the preferred approach, in some case you may
# need to place data files outside of your packages.
# see http://docs.python.org/3.4/distutils/setupscript.html#installing-additional-files
# In this case, 'data_file' will be installed into '<sys.prefix>/my_data'
data_files=[],
# To provide executable scripts, use entry points in preference to the
# "scripts" keyword. Entry points provide cross-platform support and allow
# pip to create the appropriate form of executable for the target platform.
entry_points='''
[ckan.plugins]
systeminfo=ckanext.systeminfo.plugin:SysteminfoPlugin
[babel.extractors]
ckan = ckan.lib.extract:extract_ckan
''',
# If you are changing from the default layout of your extension, you may
# have to change the message extractors, you can read more about babel
# message extraction at
# http://babel.pocoo.org/docs/messages/#extraction-method-mapping-and-configuration
message_extractors={
'ckanext': [
('**.py', 'python', None),
('**.js', 'javascript', None),
('**/templates/**.html', 'ckan', None),
],
}
)
[DEFAULT]
debug = false
smtp_server = localhost
error_email_from = paste@localhost
[server:main]
use = egg:Paste#http
host = 0.0.0.0
port = 5000
[app:main]
use = config:../ckan/test-core.ini
# Insert any custom config settings to be used when running your extension's
# tests here.
# Logging configuration
[loggers]
keys = root, ckan, sqlalchemy
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = WARN
handlers = console
[logger_ckan]
qualname = ckan
handlers =
level = INFO
[logger_sqlalchemy]
handlers =
qualname = sqlalchemy.engine
level = WARN
[handler_console]
class = StreamHandler
args = (sys.stdout,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s] %(message)s
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment