Beispiel #1
0
    def handle(self, *args, **options):
        try:
            monitor = Monitor(log, verbose_debug_mode=options[self.VERBOSE_MODE])
            monitor.debug("%s - Started scraping inmates from Cook County Sheriff's site." % datetime.now())

            scraper = Scraper(monitor)
            if options[self.START_DATE]:
                scraper.check_for_missing_inmates(datetime.strptime(options[self.START_DATE], "%Y-%m-%d").date())
            else:
                scraper.run()

            monitor.debug("%s - Finished scraping inmates from Cook County Sheriff's site." % datetime.now())
        except Exception, e:
            log.exception(e)
 def test_verbose_debug_mode(self):
     expected = 'hi'
     log = Mock()
     monitor = Monitor(log)
     monitor.debug(expected)
     monitor.debug(expected, debug_level=MONITOR_VERBOSE_DMSG_LEVEL)
     assert len(log.debug.call_args_list) == 1
     log = Mock()
     monitor = Monitor(log, verbose_debug_mode=True)
     monitor.debug(expected)
     monitor.debug(expected, debug_level=MONITOR_VERBOSE_DMSG_LEVEL)
     assert len(log.debug.call_args_list) == 2
 def test_verbose_debug_mode(self):
     expected = 'hi'
     log = Mock()
     monitor = Monitor(log)
     monitor.debug(expected)
     monitor.debug(expected, debug_level=MONITOR_VERBOSE_DMSG_LEVEL)
     assert len(log.debug.call_args_list) == 1
     log = Mock()
     monitor = Monitor(log, verbose_debug_mode=True)
     monitor.debug(expected)
     monitor.debug(expected, debug_level=MONITOR_VERBOSE_DMSG_LEVEL)
     assert len(log.debug.call_args_list) == 2
Beispiel #4
0
def ng_scraper():

    parser = argparse.ArgumentParser(
        description="Scrape inmate data from Cook County Sheriff's site.")
    parser.add_argument(
        '-d',
        '--day',
        action='store',
        dest='start_date',
        default=None,
        help=(
            'Specify day to search for missing inmates, format is YYYY-MM-DD. '
            'If not specified, searches all days.'))
    parser.add_argument('--verbose',
                        action="store_true",
                        dest='verbose',
                        default=False,
                        help='Turn on verbose mode.')

    args = parser.parse_args()

    try:
        monitor = Monitor(log, verbose_debug_mode=args.verbose)
        monitor.debug(
            "%s - Started scraping inmates from Cook County Sheriff's site." %
            datetime.now())

        scraper = Scraper(monitor)
        if args.start_date:
            scraper.check_for_missing_inmates(
                datetime.strptime(args.start_date, '%Y-%m-%d').date())
        else:
            scraper.run(date.today() - timedelta(1), feature_controls())

        monitor.debug(
            "%s - Finished scraping inmates from Cook County Sheriff's site." %
            datetime.now())
    except Exception, e:
        log.exception(e)
Beispiel #5
0
def ng_scraper():

    parser = argparse.ArgumentParser(description="Scrape inmate data from Cook County Sheriff's site.")
    parser.add_argument('-d', '--day', action='store', dest='start_date', default=None,
                        help=('Specify day to search for missing inmates, format is YYYY-MM-DD. '
                                'If not specified, searches all days.'))
    parser.add_argument('--verbose', action="store_true", dest='verbose', default=False,
                        help='Turn on verbose mode.')

    args = parser.parse_args()

    try:
        monitor = Monitor(log, verbose_debug_mode=args.verbose)
        monitor.debug("%s - Started scraping inmates from Cook County Sheriff's site." % datetime.now())

        scraper = Scraper(monitor)
        if args.start_date:
            scraper.check_for_missing_inmates(datetime.strptime(args.start_date, '%Y-%m-%d').date())
        else:
            scraper.run()

        monitor.debug("%s - Finished scraping inmates from Cook County Sheriff's site." % datetime.now())
    except Exception, e:
        log.exception(e)
 def test_debug_msgs_off(self):
     expected = 'hi'
     log = Mock()
     monitor = Monitor(log, no_debug_msgs=True)
     monitor.debug(expected)
     assert not log.debug.called, 'log.debug should not have been called'
 def test_debug_msgs_off(self):
     expected = 'hi'
     log = Mock()
     monitor = Monitor(log, no_debug_msgs=True)
     monitor.debug(expected)
     assert not log.debug.called, 'log.debug should not have been called'