Пример #1
0
 def check_for_missed_inmates(self, start_date, end_date):
     """
     Iterates over the set of possible inmates for the specified day. If the inmate has already been seen then don't
     check for them.  If an inmate is found then an entry is created for them.
     """
     log.debug("%s - Starting search for missing inmates, starting on %s" %
               (str(datetime.now()), start_date.strftime('%Y-%m-%d')))
     found_inmates = 0
     for day in self.booking_dates(start_date, end_date):
         seen_inmates = set(
             [inmate.jail_id for inmate in self.inmates_for_date(day)])
         for inmate_jail_id in self.jail_ids(day):
             if inmate_jail_id not in seen_inmates:
                 log.debug("Checking if inmate %s exists." % inmate_jail_id)
                 inmate_details = InmateDetails(
                     self.COOK_COUNTY_JAIL_INMATE_DETAILS_URL +
                     inmate_jail_id,
                     quiet=True,
                     attempts=3)
                 if inmate_details.found():
                     found_inmates += 1
                     log.debug("Found inmate %s." % inmate_jail_id)
                     create_update_inmate(inmate_details)
     log.debug(
         "%s - Ended search for missing inmates on %s, found %d." % (str(
             datetime.now()), end_date.strftime('%Y-%m-%d'), found_inmates))
Пример #2
0
 def handle(self, *args, **options):
     if options['jail_id']:
         inmate_details = InmateDetails(self.__COOK_COUNTY_INMATE_DETAILS_URL + options['jail_id'],
                                        attempts=self.__NUMBER_OF_ATTEMPTS, quiet=True)
         if inmate_details.found():
             create_update_inmate(inmate_details)
         else:
             inmate = CountyInmate.objects.get(jail_id=options['jail_id'])
             if inmate:
                 now = datetime.now()
                 inmate.discharge_date_earliest = inmate.last_seen_date
                 inmate.discharge_date_latest = now
                 inmate.save()
                 log.debug("%s - Discharged inmate %s." % (str(now), options['jail_id']))
Пример #3
0
 def handle(self, *args, **options):
     if options['jail_id']:
         inmate_details = InmateDetails(
             self.__COOK_COUNTY_INMATE_DETAILS_URL + options['jail_id'],
             attempts=self.__NUMBER_OF_ATTEMPTS,
             quiet=True)
         if inmate_details.found():
             create_update_inmate(inmate_details)
         else:
             inmate = CountyInmate.objects.get(jail_id=options['jail_id'])
             if inmate:
                 now = datetime.now()
                 inmate.discharge_date_earliest = inmate.last_seen_date
                 inmate.discharge_date_latest = now
                 inmate.save()
                 log.debug("%s - Discharged inmate %s." %
                           (str(now), options['jail_id']))
 def validate_known_inmates(self, start_date, end_date):
     updated = 0
     discharged = 0
     log.debug("%s - Starting validation of existing inmate records%s" %
               (str(datetime.now()), self.header_format_start_end_dates(start_date, end_date)))
     for inmate in self.fetch_inmates(start_date, end_date):
         log.debug("Checking inmate %s." % inmate.jail_id)
         inmate_details = InmateDetails(self.COOK_COUNTY_JAIL_INMATE_DETAILS_URL + inmate.jail_id,
                                        quiet=True, attempts=3)
         if inmate_details.found():
             updated += 1
             create_update_inmate(inmate_details, inmate)
         elif inmate.discharge_date_earliest is None:
             discharged += 1
             inmate.discharge_date_earliest = inmate.last_seen_date
             inmate.discharge_date_latest = datetime.now()
             inmate.save()
     log.debug("%s - Ended validation, updated %d and discharged %d inmate records." %
               (str(datetime.now()), updated, discharged))
 def check_for_missed_inmates(self, start_date, end_date):
     """
     Iterates over the set of possible inmates for the specified day. If the inmate has already been seen then don't
     check for them.  If an inmate is found then an entry is created for them.
     """
     log.debug("%s - Starting search for missing inmates, starting on %s" %
               (str(datetime.now()), start_date.strftime('%Y-%m-%d')))
     found_inmates = 0
     for day in self.booking_dates(start_date, end_date):
         seen_inmates = set([inmate.jail_id for inmate in self.inmates_for_date(day)])
         for inmate_jail_id in self.jail_ids(day):
             if inmate_jail_id not in seen_inmates:
                 log.debug("Checking if inmate %s exists." % inmate_jail_id)
                 inmate_details = InmateDetails(self.COOK_COUNTY_JAIL_INMATE_DETAILS_URL + inmate_jail_id, quiet=True,
                                                attempts=3)
                 if inmate_details.found():
                     found_inmates += 1
                     log.debug("Found inmate %s." % inmate_jail_id)
                     create_update_inmate(inmate_details)
     log.debug("%s - Ended search for missing inmates on %s, found %d." %
               (str(datetime.now()), end_date.strftime('%Y-%m-%d'), found_inmates))
Пример #6
0
 def validate_known_inmates(self, start_date, end_date):
     updated = 0
     discharged = 0
     log.debug("%s - Starting validation of existing inmate records%s" %
               (str(datetime.now()),
                self.header_format_start_end_dates(start_date, end_date)))
     for inmate in self.fetch_inmates(start_date, end_date):
         log.debug("Checking inmate %s." % inmate.jail_id)
         inmate_details = InmateDetails(
             self.COOK_COUNTY_JAIL_INMATE_DETAILS_URL + inmate.jail_id,
             quiet=True,
             attempts=3)
         if inmate_details.found():
             updated += 1
             create_update_inmate(inmate_details, inmate)
         elif inmate.discharge_date_earliest is None:
             discharged += 1
             inmate.discharge_date_earliest = inmate.last_seen_date
             inmate.discharge_date_latest = datetime.now()
             inmate.save()
     log.debug(
         "%s - Ended validation, updated %d and discharged %d inmate records."
         % (str(datetime.now()), updated, discharged))