Пример #1
0
    def handle(self, *args, **options):
        try:
            feed_updater.update_all()
        except Exception as e:
            raise CommandError("Something went wrong during update all: %s", e)

        self.stdout.write('Finished updating all feeds.')
Пример #2
0
    def handle(self, *args, **options):
        try:
            feed_updater.update_all()
        except Exception as e:
            raise CommandError("Something went wrong during update all: %s", e)

        self.stdout.write('Finished updating all feeds.')
Пример #3
0
def update(request):
    latest_update = None
    try:
        latest_update = Update.objects.latest()
    except Update.DoesNotExist:
        pass

    if latest_update is None or (
            latest_update.timestamp <=
        (utils.timezone.now() - datetime.timedelta(hours=1))):
        response = StreamingHttpResponse(
            streaming_content=feed_updater.update_all(with_feedback=True),
            content_type='text/plain',
            status=200)
        if latest_update is not None:
            latest_update.timestamp = utils.timezone.now()
            latest_update.save()
        else:
            Update.objects.create(timestamp=utils.timezone.now())
    else:
        response = HttpResponse(content='Wat?',
                                content_type='text/plain',
                                status=200)

    return response
Пример #4
0
def update(request):
    latest_update = None
    try:
        latest_update = Update.objects.latest()
    except Update.DoesNotExist:
        pass

    if latest_update is None or (latest_update.timestamp <= (utils.timezone.now() - datetime.timedelta(hours=1))):
        response = StreamingHttpResponse(streaming_content=feed_updater.update_all(with_feedback=True),
            content_type='text/plain', status=200)
        if latest_update is not None:
            latest_update.timestamp = utils.timezone.now()
            latest_update.save()
        else:
            Update.objects.create(timestamp=utils.timezone.now())
    else:
        response = HttpResponse(content='Wat?', content_type='text/plain', status=200)

    return response