
Nh                 @   s   d  d l  m Z m Z d  d l Z d  d l Z Gd d   d e  Z Gd d   d e  Z Gd d   d e  Z	 Gd	 d
   d
 e j
 e   Z d S)    )ABCMetaabstractmethodNc                   s(   e  Z d  Z d Z   f d d   Z   S)JobLookupErrorzBRaised when the job store cannot find a job for update or removal.c                s   t  t |   j d |  d  S)Nz No job by the id of %s was found)superr   __init__)selfjob_id)	__class__ V/mod/web/acousticsspace/venv/lib/python3.5/site-packages/apscheduler/jobstores/base.pyr   
   s    zJobLookupError.__init__)__name__
__module____qualname____doc__r   r
   r
   )r	   r   r      s   r   c                   s(   e  Z d  Z d Z   f d d   Z   S)ConflictingIdErrorz8Raised when the uniqueness of job IDs is being violated.c                s   t  t |   j d |  d  S)Nz2Job identifier (%s) conflicts with an existing job)r   r   r   )r   r   )r	   r
   r   r      s    zConflictingIdError.__init__)r   r   r   r   r   r
   r
   )r	   r   r      s   r   c                   s(   e  Z d  Z d Z   f d d   Z   S)TransientJobErrorzs
    Raised when an attempt to add transient (with no func_ref) job to a persistent job store is
    detected.
    c                s   t  t |   j d |  d  S)NzgJob (%s) cannot be added to this job store because a reference to the callable could not be determined.)r   r   r   )r   r   )r	   r
   r   r      s    zTransientJobError.__init__)r   r   r   r   r   r
   r
   )r	   r   r      s   r   c               @   s   e  Z d  Z d Z d Z d Z e j d  Z d d   Z	 d d   Z
 d d	   Z e d
 d    Z e d d    Z e d d    Z e d d    Z e d d    Z e d d    Z e d d    Z e d d    Z d d   Z d S)BaseJobStorezSAbstract base class that defines the interface that every job store must implement.Nzapscheduler.jobstoresc             C   s,   | |  _  | |  _ t j d |  |  _ d S)ax  
        Called by the scheduler when the scheduler is being started or when the job store is being
        added to an already running scheduler.

        :param apscheduler.schedulers.base.BaseScheduler scheduler: the scheduler that is starting
            this job store
        :param str|unicode alias: alias of this job store as it was assigned to the scheduler
        zapscheduler.jobstores.%sN)
_scheduler_aliaslogging	getLogger_logger)r   Z	scheduleraliasr
   r
   r   start)   s    
		zBaseJobStore.startc             C   s   d S)z2Frees any resources still bound to this job store.Nr
   )r   r
   r
   r   shutdown7   s    zBaseJobStore.shutdownc             C   sg   x` t  |  D]R \ } } | j d  k	 r | d k r^ | d  |  } | d  |  =| j |  Pq Wd  S)Nr   )	enumerateZnext_run_timeextend)r   jobsijobZpaused_jobsr
   r
   r   _fix_paused_jobs_sorting:   s    z%BaseJobStore._fix_paused_jobs_sortingc             C   s   d S)aG  
        Returns a specific job, or ``None`` if it isn't found..

        The job store is responsible for setting the ``scheduler`` and ``jobstore`` attributes of
        the returned job to point to the scheduler and itself, respectively.

        :param str|unicode job_id: identifier of the job
        :rtype: Job
        Nr
   )r   r   r
   r
   r   
lookup_jobC   s    zBaseJobStore.lookup_jobc             C   s   d S)a  
        Returns the list of jobs that have ``next_run_time`` earlier or equal to ``now``.
        The returned jobs must be sorted by next run time (ascending).

        :param datetime.datetime now: the current (timezone aware) datetime
        :rtype: list[Job]
        Nr
   )r   nowr
   r
   r   get_due_jobsO   s    zBaseJobStore.get_due_jobsc             C   s   d S)z
        Returns the earliest run time of all the jobs stored in this job store, or ``None`` if
        there are no active jobs.

        :rtype: datetime.datetime
        Nr
   )r   r
   r
   r   get_next_run_timeY   s    zBaseJobStore.get_next_run_timec             C   s   d S)a  
        Returns a list of all jobs in this job store.
        The returned jobs should be sorted by next run time (ascending).
        Paused jobs (next_run_time == None) should be sorted last.

        The job store is responsible for setting the ``scheduler`` and ``jobstore`` attributes of
        the returned jobs to point to the scheduler and itself, respectively.

        :rtype: list[Job]
        Nr
   )r   r
   r
   r   get_all_jobsb   s    zBaseJobStore.get_all_jobsc             C   s   d S)z
        Adds the given job to this store.

        :param Job job: the job to add
        :raises ConflictingIdError: if there is another job in this store with the same ID
        Nr
   )r   r   r
   r
   r   add_jobo   s    zBaseJobStore.add_jobc             C   s   d S)z
        Replaces the job in the store with the given newer version.

        :param Job job: the job to update
        :raises JobLookupError: if the job does not exist
        Nr
   )r   r   r
   r
   r   
update_jobx   s    zBaseJobStore.update_jobc             C   s   d S)z
        Removes the given job from this store.

        :param str|unicode job_id: identifier of the job
        :raises JobLookupError: if the job does not exist
        Nr
   )r   r   r
   r
   r   
remove_job   s    zBaseJobStore.remove_jobc             C   s   d S)z!Removes all jobs from this store.Nr
   )r   r
   r
   r   remove_all_jobs   s    zBaseJobStore.remove_all_jobsc             C   s   d |  j  j S)Nz<%s>)r	   r   )r   r
   r
   r   __repr__   s    zBaseJobStore.__repr__)r   r   r   r   r   r   r   r   r   r   r   r    r   r!   r#   r$   r%   r&   r'   r(   r)   r*   r
   r
   r
   r   r   "   s    	
				r   )abcr   r   r   sixKeyErrorr   r   
ValueErrorr   with_metaclassr   r
   r
   r
   r   <module>   s   