##// END OF EJS Templates
events: added new fts build event
milka -
r4583:d1df4ac3 stable
parent child Browse files
Show More
@@ -20,29 +20,9 b' import logging'
20 20 from pyramid.threadlocal import get_current_registry
21 21 from rhodecode.events.base import RhodeCodeIntegrationEvent
22 22
23
24 log = logging.getLogger(__name__)
25
26
27 def trigger(event, registry=None):
28 """
29 Helper method to send an event. This wraps the pyramid logic to send an
30 event.
31 """
32 # For the first step we are using pyramids thread locals here. If the
33 # event mechanism works out as a good solution we should think about
34 # passing the registry as an argument to get rid of it.
35 event_name = event.__class__
36 log.debug('event %s sent for execution', event_name)
37 registry = registry or get_current_registry()
38 registry.notify(event)
39 log.debug('event %s triggered using registry %s', event_name, registry)
40
41 # Send the events to integrations directly
42 from rhodecode.integrations import integrations_event_handler
43 if isinstance(event, RhodeCodeIntegrationEvent):
44 integrations_event_handler(event)
45
23 from rhodecode.events.base import ( # pragma: no cover
24 FtsBuild
25 )
46 26
47 27 from rhodecode.events.user import ( # pragma: no cover
48 28 UserPreCreate,
@@ -78,3 +58,26 b' from rhodecode.events.pullrequest import'
78 58 PullRequestMergeEvent,
79 59 PullRequestCloseEvent,
80 60 )
61
62
63 log = logging.getLogger(__name__)
64
65
66 def trigger(event, registry=None):
67 """
68 Helper method to send an event. This wraps the pyramid logic to send an
69 event.
70 """
71 # For the first step we are using pyramids thread locals here. If the
72 # event mechanism works out as a good solution we should think about
73 # passing the registry as an argument to get rid of it.
74 event_name = event.__class__
75 log.debug('event %s sent for execution', event_name)
76 registry = registry or get_current_registry()
77 registry.notify(event)
78 log.debug('event %s triggered using registry %s', event_name, registry)
79
80 # Send the events to integrations directly
81 from rhodecode.integrations import integrations_event_handler
82 if isinstance(event, RhodeCodeIntegrationEvent):
83 integrations_event_handler(event)
@@ -120,3 +120,11 b' class RhodeCodeIntegrationEvent(Rhodecod'
120 120 Special subclass for Integration events
121 121 """
122 122 description = ''
123
124
125 class FtsBuild(RhodecodeEvent):
126 """
127 This event will be triggered when FTS Build is triggered
128 """
129 name = 'fts-build'
130 display_name = 'Start FTS Build'
@@ -354,7 +354,7 b' def check_for_update():'
354 354 @async_task(ignore_result=False)
355 355 def beat_check(*args, **kwargs):
356 356 log = get_logger(beat_check)
357 log.info('Got args: %r and kwargs %r', args, kwargs)
357 log.info('%r: Got args: %r and kwargs %r', beat_check, args, kwargs)
358 358 return time.time()
359 359
360 360
@@ -3967,7 +3967,7 b' class ChangesetStatus(Base, BaseModel):'
3967 3967 STATUS_APPROVED = 'approved'
3968 3968 STATUS_REJECTED = 'rejected'
3969 3969 STATUS_UNDER_REVIEW = 'under_review'
3970
3970 CheckConstraint,
3971 3971 STATUSES = [
3972 3972 (STATUS_NOT_REVIEWED, _("Not Reviewed")), # (no icon) and default
3973 3973 (STATUS_APPROVED, _("Approved")),
@@ -5322,11 +5322,11 b' class ScheduleEntry(Base, BaseModel):'
5322 5322 except ValueError:
5323 5323 return dict()
5324 5324
5325 def _as_raw(self, val):
5325 def _as_raw(self, val, indent=None):
5326 5326 if hasattr(val, 'de_coerce'):
5327 5327 val = val.de_coerce()
5328 5328 if val:
5329 val = json.dumps(val)
5329 val = json.dumps(val, indent=indent, sort_keys=True)
5330 5330
5331 5331 return val
5332 5332
@@ -5334,13 +5334,11 b' class ScheduleEntry(Base, BaseModel):'
5334 5334 def schedule_definition_raw(self):
5335 5335 return self._as_raw(self.schedule_definition)
5336 5336
5337 @property
5338 def args_raw(self):
5339 return self._as_raw(self.task_args)
5340
5341 @property
5342 def kwargs_raw(self):
5343 return self._as_raw(self.task_kwargs)
5337 def args_raw(self, indent=None):
5338 return self._as_raw(self.task_args, indent)
5339
5340 def kwargs_raw(self, indent=None):
5341 return self._as_raw(self.task_kwargs, indent)
5344 5342
5345 5343 def __repr__(self):
5346 5344 return '<DB:ScheduleEntry({}:{})>'.format(
@@ -147,6 +147,14 b' class CloneUriValidator(object):'
147 147 def json_validator(node, value):
148 148 try:
149 149 json.loads(value)
150 except (Exception,):
150 except (Exception,) as e:
151 151 msg = _(u'Please enter a valid json object')
152 152 raise colander.Invalid(node, msg)
153
154
155 def json_validator_with_exc(node, value):
156 try:
157 json.loads(value)
158 except (Exception,) as e:
159 msg = _(u'Please enter a valid json object: `{}`'.format(e))
160 raise colander.Invalid(node, msg)
General Comments 0
You need to be logged in to leave comments. Login now