Refactor module structure

Move mysqltasks to top level to keep the task names when using Python3.
This commit is contained in:
Jan Dittberner 2020-03-04 19:55:29 +01:00
parent 2c0aa2fa92
commit ca0d8451d0
9 changed files with 42 additions and 27 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -2,12 +2,10 @@
This module defines Celery_ tasks to manage MySQL users and databases. 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 import shared_task
from celery.utils.log import get_task_logger from celery.utils.log import get_task_logger
from gvamysql import settings from mysqltasks import settings
from MySQLdb import connect from MySQLdb import connect

18
gvamysql/setup.cfg Normal file
View file

@ -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