Skip to content

Commit

Permalink
[ADD] mgmt command to delete exports older than one day
Browse files Browse the repository at this point in the history
  • Loading branch information
ierror committed Jun 18, 2012
1 parent a98b3af commit 3c5d1c1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions beautifulmind/configuration/_50_env_boerni.py
Expand Up @@ -13,7 +13,7 @@
}
}

MEDIA_URL = 'http://192.168.100.200:8000/assets/'
MEDIA_URL = 'http://192.168.100.121:8000/assets/'

#if not settings.DEBUG:
# STATIC_URL = 'http://192.168.100.200:8000/assets/static/'
Expand All @@ -22,7 +22,7 @@
DEBUG = True

MINDMAPTORNADO_BIND_PORT = 1234
MINDMAPTORNADO_SERVER = 'http://192.168.100.200:%d/ws' % (MINDMAPTORNADO_BIND_PORT)
MINDMAPTORNADO_SERVER = 'http://192.168.100.121:%d/ws' % (MINDMAPTORNADO_BIND_PORT)

CACHES = {
'default': {
Expand Down
Empty file.
20 changes: 20 additions & 0 deletions beautifulmind/mindmap/management/commands/mindmap_clean_exports.py
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
import datetime
from sockjs.tornado.router import SockJSRouter
from django.core.files.storage import default_storage
from django.core.management.base import BaseCommand
from beautifulmind.mindmap.settings import EXPORTS_SAVE_PATH


class Command(BaseCommand):
can_import_settings = True

def handle(self, *args, **options):
for exported_file in default_storage.listdir(EXPORTS_SAVE_PATH)[1]:
if exported_file == 'DONOTDELTETHISFOLDER':
continue

exported_file = '%s%s' % (EXPORTS_SAVE_PATH, exported_file)
modified_time_delta = datetime.datetime.now() - default_storage.modified_time(exported_file)
if modified_time_delta > datetime.timedelta(days=1):
default_storage.delete(exported_file)

0 comments on commit 3c5d1c1

Please sign in to comment.