Ejemplo n.º 1
0
def register_notification_listeners():
    """Register notification listeners.

  Notification listeners will be registered only if `NOTIFICATIONS_ENABLED`
  flag in settings is set to `True` value.
  """
    if not settings.NOTIFICATIONS_ENABLED:
        logger.warning(
            "Could not register notification listeners. Notifications "
            "are disabled. Use `NOTIFICATIONS_ENABLED` setting to "
            "enable notifications.")
        return

    listeners = extensions.get_module_contributions("NOTIFICATION_LISTENERS")
    for listener in listeners:
        listener()
Ejemplo n.º 2
0
    def get_service_function(cls, name):
        """Get callback function for an object.

    This returns a service function which is a registered callback for an
    object that has a notification.

    Args:
      name: Name of an object for which we want to get a service function, such
        as "CycleTask", "Assessment", etc.

    Returns:
      callable: A function that takes a notification and returns a data dict
        with all the data for that notification.
    """
        if not cls.services:
            cls.services = extensions.get_module_contributions(
                "contributed_notifications")
        if name not in cls.services:
            raise ValueError("unknown service name: %s" % name)
        return cls.services[name]
Ejemplo n.º 3
0
  def get_service_function(cls, name):
    """Get callback function for an object.

    This returns a service function which is a registered callback for an
    object that has a notification.

    Args:
      name: Name of an object for which we want to get a service function, such
        as "CycleTask", "Assessment", etc.

    Returns:
      callable: A function that takes a notification and returns a data dict
        with all the data for that notification.
    """
    if not cls.services:
      cls.services = extensions.get_module_contributions(
          "contributed_notifications")
    if name not in cls.services:
      raise ValueError("unknown service name: %s" % name)
    return cls.services[name]
Ejemplo n.º 4
0
def nightly_cron_endpoint():
    cron_jobs = extensions.get_module_contributions("CONTRIBUTED_CRON_JOBS")
    for job in cron_jobs:
        run_job(job)
    return 'Ok'
Ejemplo n.º 5
0
def job_runner(name):
    """Run all contributed jobs from all extension modules"""
    cron_jobs = extensions.get_module_contributions(name)
    for job in cron_jobs:
        run_job(job)
    return 'Ok'
Ejemplo n.º 6
0
def register_notification_listeners():
    listeners = extensions.get_module_contributions("NOTIFICATION_LISTENERS")
    for listener in listeners:
        listener()
Ejemplo n.º 7
0
def register_notification_listeners():
  listeners = extensions.get_module_contributions("NOTIFICATION_LISTENERS")
  for listener in listeners:
    listener()
Ejemplo n.º 8
0
def job_runner(name):
  cron_jobs = extensions.get_module_contributions(name)
  for job in cron_jobs:
    run_job(job)
  return 'Ok'
Ejemplo n.º 9
0
def nightly_cron_endpoint():
  cron_jobs = extensions.get_module_contributions("CONTRIBUTED_CRON_JOBS")
  for job in cron_jobs:
    run_job(job)
  return 'Ok'
Ejemplo n.º 10
0
def job_runner(name):
  """Run all contributed jobs from all extension modules"""
  cron_jobs = extensions.get_module_contributions(name)
  for job in cron_jobs:
    run_job(job)
  return 'Ok'