Skip to content

Instantly share code, notes, and snippets.

@Sovetnikov
Created February 13, 2017 19:10

Revisions

  1. Sovetnikov created this gist Feb 13, 2017.
    39 changes: 39 additions & 0 deletions run_celery_cam.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    import os
    import time
    from copy import copy

    from celery.events.snapshot import evcam

    from qiwichain import settings as novtest_settings
    from qiwichain.celery import app

    DATABASES = copy(novtest_settings.DATABASES)
    if 'postgis' in DATABASES['default']['ENGINE']:
    # Just my case, postgis asks for additional libraries, but it's not needed here
    DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2'

    from django.conf import settings

    settings.configure(
    INSTALLED_APPS=(
    'djcelery',
    ),
    TIME_ZONE=novtest_settings.TIME_ZONE,
    DATABASES=DATABASES,
    CACHES={
    'default': {
    'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
    }
    }
    )

    if hasattr(time, 'tzset'):
    # Check that it's not development server on Windows
    os.environ['TZ'] = settings.TIME_ZONE
    time.tzset()

    if __name__ == '__main__':
    import django

    django.setup()
    evcam(camera='djcelery.snapshot.Camera', app=app, loglevel='INFO', freq=1)