events: added new fts build event
This commit is contained in:
parent
16c5d9453a
commit
08e06718cd
5 changed files with 51 additions and 34 deletions
|
|
@ -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 ( # pragma: no cover
|
|||
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)
|
||||
|
|
|
|||
|
|
@ -120,3 +120,11 @@ class RhodeCodeIntegrationEvent(RhodecodeEvent):
|
|||
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'
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
def args_raw(self, indent=None):
|
||||
return self._as_raw(self.task_args, indent)
|
||||
|
||||
@property
|
||||
def kwargs_raw(self):
|
||||
return self._as_raw(self.task_kwargs)
|
||||
def kwargs_raw(self, indent=None):
|
||||
return self._as_raw(self.task_kwargs, indent)
|
||||
|
||||
def __repr__(self):
|
||||
return '<DB:ScheduleEntry({}:{})>'.format(
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue