Tox and setup.py added
* manage.py renamed to manage_collector.py * default running mode in manage_collector.py set to prod * example configuration file for uWSGI is added
This commit is contained in:
parent
fce7e1f495
commit
85c11fe3e1
14
README.md
14
README.md
|
@ -11,12 +11,12 @@ Install requirements:
|
||||||
|
|
||||||
pip install -r test-requirements.txt
|
pip install -r test-requirements.txt
|
||||||
|
|
||||||
By default manage.py works with test settings.
|
By default manage_collector.py works with prod settings.
|
||||||
For working with prod settings use `python manage.py --mode` option.
|
For working with test settings use `python manage_collector.py --mode` option.
|
||||||
|
|
||||||
For creating DB migration:
|
For creating DB migration:
|
||||||
|
|
||||||
python manage.py db migrate -m "Migration comment" \
|
python manage_collector.py --mode test db migrate -m "Migration comment" \
|
||||||
-d collector/api/db/migrations/
|
-d collector/api/db/migrations/
|
||||||
|
|
||||||
Create DB user with password 'collector':
|
Create DB user with password 'collector':
|
||||||
|
@ -36,12 +36,14 @@ Create DB and grant privileges to it:
|
||||||
|
|
||||||
For apply the latest migration:
|
For apply the latest migration:
|
||||||
|
|
||||||
python manage.py db upgrade -d collector/api/db/migrations/
|
python manage_collector.py --mode test db upgrade -d collector/api/db/migrations/
|
||||||
|
|
||||||
For revert all migrations:
|
For revert all migrations:
|
||||||
|
|
||||||
python manage.py db downgrade -d collector/api/db/migrations/
|
python manage_collector.py --mode test db downgrade -d collector/api/db/migrations/
|
||||||
|
|
||||||
For starting test server:
|
For starting test server:
|
||||||
|
|
||||||
python manage.py runserver
|
python manage_collector.py --mode test runserver
|
||||||
|
|
||||||
|
Example config for uWSGI is located in collector/uwsgi/collector_test.yaml
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Migration manager
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from flask_migrate import Migrate
|
from flask_migrate import Migrate
|
||||||
from flask_migrate import MigrateCommand
|
from flask_migrate import MigrateCommand
|
||||||
|
@ -21,7 +21,7 @@ def configure_app(mode=None):
|
||||||
|
|
||||||
manager = Manager(configure_app)
|
manager = Manager(configure_app)
|
||||||
manager.add_option('--mode', help="Acceptable modes. Default: 'test'",
|
manager.add_option('--mode', help="Acceptable modes. Default: 'test'",
|
||||||
choices=('test', 'prod'), default='test', dest='mode')
|
choices=('test', 'prod'), default='prod', dest='mode')
|
||||||
|
|
||||||
migrate = Migrate(app, db)
|
migrate = Migrate(app, db)
|
||||||
manager.add_command('db', MigrateCommand)
|
manager.add_command('db', MigrateCommand)
|
|
@ -0,0 +1,45 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
from setuptools import find_packages
|
||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
|
||||||
|
def parse_requirements_txt():
|
||||||
|
root = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
requirements = []
|
||||||
|
with open(os.path.join(root, 'requirements.txt'), 'r') as f:
|
||||||
|
for line in f.readlines():
|
||||||
|
line = line.rstrip()
|
||||||
|
if not line or line.startswith('#'):
|
||||||
|
continue
|
||||||
|
requirements.append(line)
|
||||||
|
return requirements
|
||||||
|
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name='collector',
|
||||||
|
version='0.0.1',
|
||||||
|
description="Service of collecting anonymous statistics",
|
||||||
|
long_description="""Service of collecting anonymous statistics""",
|
||||||
|
license="http://www.apache.org/licenses/LICENSE-2.0",
|
||||||
|
classifiers=[
|
||||||
|
"License :: OSI Approved :: Apache Software License",
|
||||||
|
"Development Status :: 3 - Alpha",
|
||||||
|
"Programming Language :: Python",
|
||||||
|
"Topic :: Internet :: WWW/HTTP",
|
||||||
|
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
|
||||||
|
],
|
||||||
|
author='Mirantis Inc.',
|
||||||
|
author_email='product@mirantis.com',
|
||||||
|
url='https://mirantis.com',
|
||||||
|
keywords='fuel anonymous statistics collector mirantis',
|
||||||
|
packages=find_packages(),
|
||||||
|
zip_safe=False,
|
||||||
|
install_requires=parse_requirements_txt(),
|
||||||
|
include_package_data=True,
|
||||||
|
scripts=['manage_collector.py'],
|
||||||
|
# entry_points={
|
||||||
|
# 'console_scripts': [
|
||||||
|
# 'upgrade_db = collector.cli:main']
|
||||||
|
# }
|
||||||
|
)
|
|
@ -1,3 +1,7 @@
|
||||||
-r requirements.txt
|
-r requirements.txt
|
||||||
unittest2
|
unittest2
|
||||||
mock
|
mock
|
||||||
|
nose
|
||||||
|
hacking
|
||||||
|
nose2
|
||||||
|
tox
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
[tox]
|
||||||
|
minversion = 1.6
|
||||||
|
skipsdist = True
|
||||||
|
envlist = py27,pep8
|
||||||
|
|
||||||
|
[testenv]
|
||||||
|
usedevelop = True
|
||||||
|
install_command = pip install {packages}
|
||||||
|
setenv = VIRTUAL_ENV={envdir}
|
||||||
|
deps = -r{toxinidir}/test-requirements.txt
|
||||||
|
commands =
|
||||||
|
nosetests {posargs:collector/test}
|
||||||
|
|
||||||
|
[tox:jenkins]
|
||||||
|
downloadcache = ~/cache/pip
|
||||||
|
|
||||||
|
[testenv:pep8]
|
||||||
|
deps = hacking==0.7
|
||||||
|
usedevelop = False
|
||||||
|
commands =
|
||||||
|
flake8 {posargs:collector}
|
||||||
|
|
||||||
|
[testenv:cover]
|
||||||
|
setenv = NOSE_WITH_COVERAGE=1
|
||||||
|
|
||||||
|
[testenv:venv]
|
||||||
|
deps = -r{toxinidir}/test-requirements.txt
|
||||||
|
commands = {posargs:}
|
||||||
|
|
||||||
|
[testenv:devenv]
|
||||||
|
envdir = devenv
|
||||||
|
usedevelop = True
|
||||||
|
|
||||||
|
[flake8]
|
||||||
|
ignore = H234,H302,H802
|
||||||
|
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,__init__.py,docs
|
||||||
|
show-pep8 = True
|
||||||
|
show-source = True
|
||||||
|
count = True
|
||||||
|
|
||||||
|
[hacking]
|
||||||
|
import_exceptions = testtools.matchers
|
|
@ -0,0 +1,5 @@
|
||||||
|
uwsgi:
|
||||||
|
socket: :8081
|
||||||
|
module: collector.api.app
|
||||||
|
callable: app
|
||||||
|
protocol: http
|
Loading…
Reference in New Issue