# Path: libre/apps/scheduler/exceptions.py
# class AlreadyScheduled(Exception):
#     """
#     Raised when trying to schedule a Job instance of anything after it was
#     already scheduled in any other scheduler
#     """
#     pass
# 
# class UnknownJob(Exception):
#     pass
# 
# class UnknownJobClass(Exception):
#     """
#     Raised when trying to schedule a Job that is not of a a type:
#     IntervalJob or DateJob
#     """
#     pass


import logging
from apscheduler.scheduler import Scheduler as OriginalScheduler
from django.utils.translation import ugettext_lazy as _
from .exceptions import AlreadyScheduled, UnknownJob, UnknownJobClass


class LocalScheduler(object):
    scheduler_registry = {}
    _lockdown = False

    @classmethod
    def get(cls, name):
        return cls.scheduler_registry[name]

    @classmethod
    def get_all(cls):
        return cls.scheduler_registry.values()

    @classmethod
    def shutdown_all(cls):
        for scheduler in cls.scheduler_registry.values():
            scheduler.stop()

    @classmethod
    def lockdown(cls):
        cls._lockdown = True

    @classmethod
    def clear_all(cls):
        for scheduler in cls.scheduler_registry.values():
            scheduler.clear()

    def __init__(self, name, label=None):
        self.scheduled_jobs = {}

# Path: libre/apps/scheduler/exceptions.py
# class AlreadyScheduled(Exception):
#     """
#     Raised when trying to schedule a Job instance of anything after it was
#     already scheduled in any other scheduler
#     """
#     pass
# 
# class UnknownJob(Exception):
#     pass
# 
# class UnknownJobClass(Exception):
#     """
#     Raised when trying to schedule a Job that is not of a a type:
#     IntervalJob or DateJob
#     """
#     pass


# Path: libre/apps/scheduler/classes.py
import logging
from apscheduler.scheduler import Scheduler as OriginalScheduler
from django.utils.translation import ugettext_lazy as _
from .exceptions import AlreadyScheduled, UnknownJob, UnknownJobClass



class LocalScheduler(object):
    scheduler_registry = {}
    _lockdown = False

    @classmethod
    def get(cls, name):
        return cls.scheduler_registry[name]

    @classmethod
    def get_all(cls):
        return cls.scheduler_registry.values()

    @classmethod
    def shutdown_all(cls):
        for scheduler in cls.scheduler_registry.values():
            scheduler.stop()

    @classmethod
    def lockdown(cls):
        cls._lockdown = True

    @classmethod
    def clear_all(cls):
        for scheduler in cls.scheduler_registry.values():
            scheduler.clear()

    def __init__(self, name, label=None):
        self.scheduled_jobs = {}

        self._scheduler = None