# Path: utils.py
# ONE_DAY = timedelta(1)


from datetime import date
from gevent.queue import Queue
from heartbeat import Heartbeat
from search_commands import SearchCommands
from utils import ONE_DAY
import gevent
                if msg == self.STOP_COMMAND:
                    keep_running = False
                elif notifier == self._search_commands.__class__:
                    if msg == SearchCommands.FINISHED_FIND_INMATES:
                        self._debug('inmates scraper finish')
                        self._inmate_scraper.finish()
                    else:
                        self._debug('Unknown notification from %s, received - %s' % (notifier, msg))
                elif notifier == self._inmate_scraper.__class__:
                    self._debug('inmates finish')
                    self._inmates.finish()
                elif notifier == self._inmates.__class__:
                    keep_running = False
                elif notifier == self.__class__:
                    if msg == self._START_COMMAND:
                        self._debug('find known inmates')
                        self._known_inmates()
                    elif msg == self._RECEIVED_KNOWN_INMATES_COMMAND:
                        self._debug('find missing inmates')
                        self._search_commands.find_inmates(exclude_list=self._inmates_response,
                                                           start_date=self._start_date_missing_inmates)
                else:
                    self._debug('Unknown notification from %s, received - %s' % (notifier, msg))
        self._start_date_missing_inmates = None
        self.is_running = False
        self._debug('find_missing_inmates stopped')

    def _find_new_inmates(self):
        end_index = self._end_index_active_inmate_ids_in_search_window()
        self._search_commands.find_inmates(exclude_list=self._active_inmate_ids[0:end_index],

# Path: utils.py
# ONE_DAY = timedelta(1)


# Path: scraper/controller.py
from datetime import date
from gevent.queue import Queue
from heartbeat import Heartbeat
from search_commands import SearchCommands
from utils import ONE_DAY
import gevent

                if msg == self.STOP_COMMAND:
                    keep_running = False
                elif notifier == self._search_commands.__class__:
                    if msg == SearchCommands.FINISHED_FIND_INMATES:
                        self._debug('inmates scraper finish')
                        self._inmate_scraper.finish()
                    else:
                        self._debug('Unknown notification from %s, received - %s' % (notifier, msg))
                elif notifier == self._inmate_scraper.__class__:
                    self._debug('inmates finish')
                    self._inmates.finish()
                elif notifier == self._inmates.__class__:
                    keep_running = False
                elif notifier == self.__class__:
                    if msg == self._START_COMMAND:
                        self._debug('find known inmates')
                        self._known_inmates()
                    elif msg == self._RECEIVED_KNOWN_INMATES_COMMAND:
                        self._debug('find missing inmates')
                        self._search_commands.find_inmates(exclude_list=self._inmates_response,
                                                           start_date=self._start_date_missing_inmates)
                else:
                    self._debug('Unknown notification from %s, received - %s' % (notifier, msg))
        self._start_date_missing_inmates = None
        self.is_running = False
        self._debug('find_missing_inmates stopped')

    def _find_new_inmates(self):
        end_index = self._end_index_active_inmate_ids_in_search_window()
        self._search_commands.find_inmates(exclude_list=self._active_inmate_ids[0:end_index],

                                           start_date=self._today - ONE_DAY * (NEW_INMATE_SEARCH_WINDOW_SIZE + 1))