Browse Source

Refactor module structure

Move mysqltasks to top level to keep the task names when using Python3.
master
Jan Dittberner 2 years ago
parent
commit
ca0d8451d0
  1. 2
      docs/changelog.rst
  2. 3
      gvamysql/gvacommon/.gitignore
  3. 4
      gvamysql/gvacommon/celeryrouters.py
  4. 0
      gvamysql/gvamysql/__init__.py
  5. 6
      gvamysql/mysqltasks/__init__.py
  6. 6
      gvamysql/mysqltasks/celery.py
  7. 26
      gvamysql/mysqltasks/settings.py
  8. 4
      gvamysql/mysqltasks/tasks.py
  9. 18
      gvamysql/setup.cfg

2
docs/changelog.rst

@ -1,6 +1,8 @@
Changelog
=========
* :support:`-` move mysqltasks to top level to keep the task names when
using Python 3
* :support:`-` drop old requirements files
* :release:`0.1.2 <2020-02-29>`

3
gvamysql/gvacommon/.gitignore

@ -1,3 +0,0 @@
.*.swp
*.pyc
.ropeproject/

4
gvamysql/gvacommon/celeryrouters.py

@ -1,9 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
class GvaRouter(object):
def route_for_task(self, task, args=None, kwargs=None):
for route in ['ldap', 'file', 'mysql', 'pgsql']:
if route in task:

0
gvamysql/gvamysql/__init__.py

6
gvamysql/mysqltasks/__init__.py

@ -1,3 +1,9 @@
"""
This module contains :py:mod:`mysqltasks.tasks`.
"""
__version__ = "0.2.0"
from mysqltasks.celery import app as celery_app
__all__ = ('celery_app',)

6
gvamysql/gvamysql/celery.py → gvamysql/mysqltasks/celery.py

@ -9,7 +9,7 @@ from __future__ import absolute_import
from celery import Celery
#: The Celery application
app = Celery('gvamysql')
app = Celery("mysqltasks")
app.config_from_object('gvamysql.settings')
app.autodiscover_tasks(['mysqltasks'], force=True)
app.config_from_object("mysqltasks.settings", namespace="CELERY")
app.autodiscover_tasks(["mysqltasks.tasks"], force=True)

26
gvamysql/gvamysql/settings.py → gvamysql/mysqltasks/settings.py

@ -25,23 +25,21 @@ def get_env_setting(setting):
########## CELERY CONFIGURATION
CELERY_TIMEZONE = 'Europe/Berlin'
CELERY_ENABLE_UTC = True
CELERY_RESULT_BACKEND = 'amqp'
CELERY_BROKER_URL = get_env_setting("GVAMYSQL_BROKER_URL")
CELERY_RESULT_BACKEND = get_env_setting("GVAMYSQL_RESULT_REDIS_URL")
CELERY_RESULT_PERSISTENT = True
CELERY_TASK_RESULT_EXPIRES = None
CELERY_ROUTES = (
'gvacommon.celeryrouters.GvaRouter',
)
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
BROKER_URL = get_env_setting('GVAMYSQL_BROKER_URL')
CELERY_ROUTES = ("gvacommon.celeryrouters.GvaRouter",)
CELERY_TIMEZONE = "Europe/Berlin"
CELERY_ENABLE_UTC = True
CELERY_ACCEPT_CONTENT = ["json"]
CELERY_TASK_SERIALIZER = "json"
CELERY_RESULT_SERIALIZER = "json"
########## END CELERY CONFIGURATION
########## GVAMYSQL CONFIGURATION
GVAMYSQL_DBADMIN_HOST = get_env_setting('GVAMYSQL_DBADMIN_HOST')
GVAMYSQL_DBADMIN_PORT = int(get_env_setting('GVAMYSQL_DBADMIN_PORT'))
GVAMYSQL_DBADMIN_USER = get_env_setting('GVAMYSQL_DBADMIN_USER')
GVAMYSQL_DBADMIN_PASSWORD = get_env_setting('GVAMYSQL_DBADMIN_PASSWORD')
GVAMYSQL_DBADMIN_HOST = get_env_setting("GVAMYSQL_DBADMIN_HOST")
GVAMYSQL_DBADMIN_PORT = int(get_env_setting("GVAMYSQL_DBADMIN_PORT"))
GVAMYSQL_DBADMIN_USER = get_env_setting("GVAMYSQL_DBADMIN_USER")
GVAMYSQL_DBADMIN_PASSWORD = get_env_setting("GVAMYSQL_DBADMIN_PASSWORD")
########## END GVAMYSQL CONFIGURATION

4
gvamysql/mysqltasks/tasks.py

@ -2,12 +2,10 @@
This module defines Celery_ tasks to manage MySQL users and databases.
"""
from __future__ import absolute_import, unicode_literals
from celery import shared_task
from celery.utils.log import get_task_logger
from gvamysql import settings
from mysqltasks import settings
from MySQLdb import connect

18
gvamysql/setup.cfg

@ -0,0 +1,18 @@
[coverage:run]
source = gvacommon,mysqltasks
branch = True
omit = */tests/*.py,*/tests.py
relative_files = True
[coverage:report]
show_missing = True
[coverage:html]
directory = ../coverage-report
[isort]
multi_line_output = 3
line_length = 88
known_third_party = celery,MySQLdb
include_trailing_comma = True
sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
Loading…
Cancel
Save