Commit 64781e7e895891b0c97fb41cf66e8c63121af958
1 parent
1a166d1d
Exists in
master
and in
29 other branches
Allow full plugins on /etc/colab/plugins.d
Signed-off-by: Sergio Oliveira <sergio@tracy.com.br>
Showing
2 changed files
with
13 additions
and
10 deletions
Show diff stats
colab/plugins/tasks.py
| ... | ... | @@ -2,10 +2,10 @@ |
| 2 | 2 | from datetime import timedelta |
| 3 | 3 | from celery.decorators import periodic_task |
| 4 | 4 | |
| 5 | -from .utils import data | |
| 5 | +from .data import TASKS | |
| 6 | 6 | |
| 7 | 7 | |
| 8 | -@periodic_task(run_every=timedelta(minutes=1)) | |
| 8 | +@periodic_task(run_every=timedelta(seconds=5)) | |
| 9 | 9 | def import_plugin_data(): |
| 10 | - for task in data.TASKS: | |
| 10 | + for task in TASKS: | |
| 11 | 11 | task.delay() | ... | ... |
colab/utils/conf.py
| ... | ... | @@ -3,7 +3,6 @@ import os |
| 3 | 3 | import sys |
| 4 | 4 | import logging |
| 5 | 5 | import importlib |
| 6 | -import warnings | |
| 7 | 6 | |
| 8 | 7 | from django.core.exceptions import ImproperlyConfigured |
| 9 | 8 | |
| ... | ... | @@ -96,17 +95,21 @@ def load_colab_apps(): |
| 96 | 95 | return {'COLAB_APPS': COLAB_APPS} |
| 97 | 96 | |
| 98 | 97 | for file_name in os.listdir(plugins_dir): |
| 99 | - if not file_name.endswith('.py'): | |
| 100 | - continue | |
| 101 | - | |
| 102 | 98 | file_module = file_name.split('.')[0] |
| 99 | + | |
| 100 | + logger.info('Loaded plugin settings: %s%s', plugins_dir, file_name) | |
| 103 | 101 | py_settings_d = _load_py_file(file_module, plugins_dir) |
| 104 | - logger.info('Loaded plugin settings: %s/%s', plugins_dir, file_name) | |
| 105 | 102 | |
| 106 | - app_name = py_settings_d.get('name') | |
| 103 | + if os.path.isdir(os.path.join(plugins_dir, file_name)): | |
| 104 | + app_name = file_name | |
| 105 | + | |
| 106 | + elif file_name.endswith('.py'): | |
| 107 | + app_name = py_settings_d.get('name') | |
| 108 | + | |
| 107 | 109 | if not app_name: |
| 108 | - warnings.warn("Plugin missing name variable") | |
| 110 | + logger.warning("Plugin missing name variable (%s)", file_name) | |
| 109 | 111 | continue |
| 112 | + | |
| 110 | 113 | try: |
| 111 | 114 | importlib.import_module(app_name) |
| 112 | 115 | except ImportError: | ... | ... |