base.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import time
  2. from django.conf import settings
  3. from django.core.management import base
  4. from misago.datamover import OLD_FORUM
  5. CommandError = base.CommandError
  6. class BaseCommand(base.BaseCommand):
  7. def execute(self, *args, **options):
  8. self.check_move_setup()
  9. return super(BaseCommand, self).execute(*args, **options)
  10. def check_move_setup(self):
  11. if not 'misago05' in settings.DATABASES:
  12. raise CommandError(
  13. "You need to configure connection for your old database by "
  14. "adding \"misago05\" connection to your DATABASES"
  15. )
  16. if not OLD_FORUM:
  17. raise CommandError(
  18. "You need to configure migration from old forum by defining "
  19. "MISAGO_OLD_FORUM setting in your settings.py"
  20. )
  21. def start_timer(self):
  22. self._timer = time.time()
  23. def stop_timer(self):
  24. total_time = time.time() - self._timer
  25. return time.strftime('%H:%M:%S', time.gmtime(total_time))