diff --git a/rhodecode/events/__init__.py b/rhodecode/events/__init__.py --- a/rhodecode/events/__init__.py +++ b/rhodecode/events/__init__.py @@ -20,29 +20,9 @@ import logging from pyramid.threadlocal import get_current_registry from rhodecode.events.base import RhodeCodeIntegrationEvent - -log = logging.getLogger(__name__) - - -def trigger(event, registry=None): - """ - Helper method to send an event. This wraps the pyramid logic to send an - event. - """ - # For the first step we are using pyramids thread locals here. If the - # event mechanism works out as a good solution we should think about - # passing the registry as an argument to get rid of it. - event_name = event.__class__ - log.debug('event %s sent for execution', event_name) - registry = registry or get_current_registry() - registry.notify(event) - log.debug('event %s triggered using registry %s', event_name, registry) - - # Send the events to integrations directly - from rhodecode.integrations import integrations_event_handler - if isinstance(event, RhodeCodeIntegrationEvent): - integrations_event_handler(event) - +from rhodecode.events.base import ( # pragma: no cover + FtsBuild +) from rhodecode.events.user import ( # pragma: no cover UserPreCreate, @@ -78,3 +58,26 @@ from rhodecode.events.pullrequest import PullRequestMergeEvent, PullRequestCloseEvent, ) + + +log = logging.getLogger(__name__) + + +def trigger(event, registry=None): + """ + Helper method to send an event. This wraps the pyramid logic to send an + event. + """ + # For the first step we are using pyramids thread locals here. If the + # event mechanism works out as a good solution we should think about + # passing the registry as an argument to get rid of it. + event_name = event.__class__ + log.debug('event %s sent for execution', event_name) + registry = registry or get_current_registry() + registry.notify(event) + log.debug('event %s triggered using registry %s', event_name, registry) + + # Send the events to integrations directly + from rhodecode.integrations import integrations_event_handler + if isinstance(event, RhodeCodeIntegrationEvent): + integrations_event_handler(event) diff --git a/rhodecode/events/base.py b/rhodecode/events/base.py --- a/rhodecode/events/base.py +++ b/rhodecode/events/base.py @@ -120,3 +120,11 @@ class RhodeCodeIntegrationEvent(Rhodecod Special subclass for Integration events """ description = '' + + +class FtsBuild(RhodecodeEvent): + """ + This event will be triggered when FTS Build is triggered + """ + name = 'fts-build' + display_name = 'Start FTS Build' diff --git a/rhodecode/lib/celerylib/tasks.py b/rhodecode/lib/celerylib/tasks.py --- a/rhodecode/lib/celerylib/tasks.py +++ b/rhodecode/lib/celerylib/tasks.py @@ -354,7 +354,7 @@ def check_for_update(): @async_task(ignore_result=False) def beat_check(*args, **kwargs): log = get_logger(beat_check) - log.info('Got args: %r and kwargs %r', args, kwargs) + log.info('%r: Got args: %r and kwargs %r', beat_check, args, kwargs) return time.time() diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -3967,7 +3967,7 @@ class ChangesetStatus(Base, BaseModel): STATUS_APPROVED = 'approved' STATUS_REJECTED = 'rejected' STATUS_UNDER_REVIEW = 'under_review' - + CheckConstraint, STATUSES = [ (STATUS_NOT_REVIEWED, _("Not Reviewed")), # (no icon) and default (STATUS_APPROVED, _("Approved")), @@ -5322,11 +5322,11 @@ class ScheduleEntry(Base, BaseModel): except ValueError: return dict() - def _as_raw(self, val): + def _as_raw(self, val, indent=None): if hasattr(val, 'de_coerce'): val = val.de_coerce() if val: - val = json.dumps(val) + val = json.dumps(val, indent=indent, sort_keys=True) return val @@ -5334,13 +5334,11 @@ class ScheduleEntry(Base, BaseModel): def schedule_definition_raw(self): return self._as_raw(self.schedule_definition) - @property - def args_raw(self): - return self._as_raw(self.task_args) - - @property - def kwargs_raw(self): - return self._as_raw(self.task_kwargs) + def args_raw(self, indent=None): + return self._as_raw(self.task_args, indent) + + def kwargs_raw(self, indent=None): + return self._as_raw(self.task_kwargs, indent) def __repr__(self): return ''.format( diff --git a/rhodecode/model/validation_schema/validators.py b/rhodecode/model/validation_schema/validators.py --- a/rhodecode/model/validation_schema/validators.py +++ b/rhodecode/model/validation_schema/validators.py @@ -147,6 +147,14 @@ class CloneUriValidator(object): def json_validator(node, value): try: json.loads(value) - except (Exception,): + except (Exception,) as e: msg = _(u'Please enter a valid json object') raise colander.Invalid(node, msg) + + +def json_validator_with_exc(node, value): + try: + json.loads(value) + except (Exception,) as e: + msg = _(u'Please enter a valid json object: `{}`'.format(e)) + raise colander.Invalid(node, msg)