3 from django.core.management.base import NoArgsCommand
 
   5 OK_MESSAGE = "  Found %(what)s version %(version)s - OK"
 
   7 OLD_VERSION_ERROR = """  ERROR: Found %(what)s version %(version)s - you should upgrade it to at least %(minimum)s.
 
   8                 Package installers like apt-get or yum usually maintain old versions of libraries in the repositories."""
 
  10 NOT_FOUND_ERROR = "ERROR: %(what)s was not found on your system."
 
  12 HOW_TO_INSTALL = """  Try easy_install %(what)s or download it from %(where)s"""
 
  14 IMPORT_ERROR_MESSAGE = """Importing %(what)s is throwing an exception. Here's the full stack trace:"""
 
  16 class Command(NoArgsCommand):
 
  17     def handle_noargs(self, **options):
 
  18         print "Checking dependencies:"
 
  22             print "  Found html5lib - OK"
 
  24             print NOT_FOUND_ERROR % dict(what='html5lib')
 
  25             print HOW_TO_INSTALL % dict(what='html5lib', where='http://code.google.com/p/html5lib/')
 
  27             print IMPORT_ERROR_MESSAGE % dict(what='html5lib')
 
  28             traceback.print_exc(file=sys.stdout)
 
  32             version = int(re.findall('^\d+', markdown.version)[0])
 
  34                 print OLD_VERSION_ERROR % dict(what='markdown', version=markdown.version, minimum='2.0')
 
  35                 print HOW_TO_INSTALL % dict(what='markdown', where='http://www.freewisdom.org/projects/python-markdown/')
 
  37                 print OK_MESSAGE % dict(what='markdown', version=markdown.version)
 
  39             print NOT_FOUND_ERROR % dict(what='markdown')
 
  40             print HOW_TO_INSTALL % dict(what='markdown', where='http://www.freewisdom.org/projects/python-markdown/')
 
  42             print IMPORT_ERROR_MESSAGE % dict(what='markdown')
 
  43             traceback.print_exc(file=sys.stdout)
 
  47             version = re.findall('\d+', south.__version__)
 
  49             if int(version[1]) < 6 and int(version[0]) == 0:
 
  50                 print OLD_VERSION_ERROR % dict(what='south', version=south.__version__, minimum='0.6')
 
  51                 print HOW_TO_INSTALL % dict(what='south', where='http://south.aeracode.org/')
 
  53                 print OK_MESSAGE % dict(what='south', version=south.__version__)
 
  57             print NOT_FOUND_ERROR % dict(what='south')
 
  58             print HOW_TO_INSTALL % dict(what='south', where='http://south.aeracode.org/')
 
  60             print IMPORT_ERROR_MESSAGE % dict(what='south')
 
  61             traceback.print_exc(file=sys.stdout)
 
  64         print "\n\nChecking database connection:"
 
  67             from forum.models import User
 
  68             User.objects.all().count()
 
  69             print "  Connection OK"
 
  71             print "There seems to be a problem with your database: %s" % str(e)
 
  75         from django.conf import settings
 
  77         print "\n\nChecking important settings:"
 
  79         if not re.match('^https?:\/\/\w+', settings.APP_URL):
 
  80             print " Your APP_URL does not seem to be a valid url. Please fill this setting with the URL of your OSQA installation"
 
  82             print " APP_URL - %s" % settings.APP_URL
 
  83             print " APP_BASE_URL - %s" % settings.APP_BASE_URL