def handle(self, *args, **options):
        ensure_phantomjs_is_runnable()
        log_handler = configure_log_handler('allthescreenshots',
                                            options['loglevel'], options['output'])

        starttime = datetime.datetime.now()
        with logbook.NullHandler():
            with log_handler.applicationbound():
                for url in ElectionUrl.objects.all():
                    url.take_screenshot()

        if options['forever']:
            now = datetime.datetime.now()
            cycle = datetime.timedelta(seconds=300)
            duration = now - starttime
            if duration <= cycle:
                remainder = cycle - duration
                log.notice("Sleeping {sec} seconds before cycling.", sec=remainder.total_seconds())
                time.sleep(remainder.total_seconds())
            restart_process()
Exemple #2
0
    def handle(self, *args, **options):
        ensure_phantomjs_is_runnable()
        log_handler = configure_log_handler('allthescreenshots',
                                            options['loglevel'],
                                            options['output'])

        starttime = datetime.datetime.now()
        with logbook.NullHandler():
            with log_handler.applicationbound():
                for url in ElectionUrl.objects.all():
                    url.take_screenshot()

        if options['forever']:
            now = datetime.datetime.now()
            cycle = datetime.timedelta(seconds=300)
            duration = now - starttime
            if duration <= cycle:
                remainder = cycle - duration
                log.notice("Sleeping {sec} seconds before cycling.",
                           sec=remainder.total_seconds())
                time.sleep(remainder.total_seconds())
            restart_process()