cron.py 852 B

12345678910111213141516171819202122232425
  1. from django.conf import settings
  2. from django.core import management
  3. # Simple cron app from https://github.com/jsocol/django-cronjobs
  4. import cronjobs
  5. @cronjobs.register
  6. def upload_static_media_to_s3():
  7. # Sync assets, exclude uploads, etc.
  8. management.call_command('s3sync_media', verbosity=1, interactive=False,
  9. remove_missing=True,
  10. exclude_list=['.*', 'Thumbs.db', 'uploads*', 'less'],
  11. bucket=settings.BUCKET_ASSETS,
  12. prefix=settings.BUCKET_ASSETS_PREFIX)
  13. @cronjobs.register
  14. def upload_user_media_to_s3():
  15. # Sync assets, exclude uploads, etc.
  16. management.call_command('s3sync_media', verbosity=1, interactive=False,
  17. exclude_list=['.htaccess'], remove_missing=True,
  18. dir=settings.BUCKET_UPLOADS_PATH,
  19. bucket=settings.BUCKET_UPLOADS,
  20. prefix=settings.BUCKET_UPLOADS_PREFIX)