Added task manager that responds to tasks mentioned in SVN logs.
The task manager doesn't do anything yet, it just logs the fact that a task has been mentioned.
This commit is contained in:
@@ -1,12 +1,16 @@
|
|||||||
from pillar.extension import PillarExtension
|
from pillar.extension import PillarExtension
|
||||||
|
|
||||||
from .modules import blueprint
|
from .modules import blueprint
|
||||||
|
from . import task_manager
|
||||||
|
|
||||||
|
|
||||||
class AttractExtension(PillarExtension):
|
class AttractExtension(PillarExtension):
|
||||||
|
def __init__(self):
|
||||||
|
self.task_manager = task_manager.TaskManager()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
return 'Attract'
|
return 'attract'
|
||||||
|
|
||||||
def flask_config(self):
|
def flask_config(self):
|
||||||
"""Returns extension-specific defaults for the Flask configuration.
|
"""Returns extension-specific defaults for the Flask configuration.
|
||||||
@@ -52,3 +56,10 @@ class AttractExtension(PillarExtension):
|
|||||||
:rtype: list of flask.Blueprint objects.
|
:rtype: list of flask.Blueprint objects.
|
||||||
"""
|
"""
|
||||||
return [blueprint]
|
return [blueprint]
|
||||||
|
|
||||||
|
def setup_app(self, app):
|
||||||
|
"""Connects Blinker signals."""
|
||||||
|
|
||||||
|
from . import subversion
|
||||||
|
|
||||||
|
subversion.task_logged.connect(self.task_manager.task_logged_in_svn)
|
||||||
|
21
attract_server/task_manager.py
Normal file
21
attract_server/task_manager.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
"""Task management."""
|
||||||
|
|
||||||
|
import attr
|
||||||
|
|
||||||
|
from . import attrs_extra
|
||||||
|
|
||||||
|
|
||||||
|
@attr.s
|
||||||
|
class TaskManager(object):
|
||||||
|
_log = attrs_extra.log('%s.TaskManager' % __name__)
|
||||||
|
|
||||||
|
def task_logged_in_svn(self, sender, task_id, log_entry):
|
||||||
|
"""Blinker signal receiver; connects the logged commit with the task.
|
||||||
|
|
||||||
|
:param sender: sender of the signal
|
||||||
|
:type sender: attract_server.subversion.CommitLogObserver
|
||||||
|
:param task_info: {'task_id': '123', 'log_entry': LogEntry} dict.
|
||||||
|
:type task_info: dict
|
||||||
|
"""
|
||||||
|
|
||||||
|
self._log.info("Task '%s' logged in SVN: %s", task_id, log_entry)
|
Reference in New Issue
Block a user