Browse Source

improve Sites checks to detect SITE_ID not set or no site of that ID existing, see #30

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
f0b567e7a7
  1. 29
      pyweb/mumble/management/commands/checkenv.py

29
pyweb/mumble/management/commands/checkenv.py

@ -30,7 +30,7 @@ class Command( BaseCommand ):
statinfo = os.stat( settings.DATABASE_NAME ); statinfo = os.stat( settings.DATABASE_NAME );
if statinfo.st_uid == 0: if statinfo.st_uid == 0:
raise TestFailed( ""
raise TestFailed(
"the database file belongs to root. This is most certainly not what " "the database file belongs to root. This is most certainly not what "
"you want because it will prevent your web server from being able " "you want because it will prevent your web server from being able "
"to write to it. Please check." ); "to write to it. Please check." );
@ -48,16 +48,33 @@ class Command( BaseCommand ):
def check_sites( self ): def check_sites( self ):
print "Checking URL configuration...", print "Checking URL configuration...",
site = Site.objects.get_current();
try:
site = Site.objects.get_current();
except Site.DoesNotExist:
try:
sid = settings.SITE_ID
except AttributeError:
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured(
"You're using the Django \"sites framework\" without having set the SITE_ID "
"setting. Create a site in your database and rerun this command to fix this error.")
else:
print( "none set.\n"
"Please enter the domain where Mumble-Django is reachable." );
dom = raw_input( "> " ).strip();
site = Site( id=sid, name=dom, domain=dom );
site.save();
if site.domain == 'example.com': if site.domain == 'example.com':
print( "The domain is configured as example.com, which is the default but does not make sense."
print( "still the default.\n"
"The domain is configured as example.com, which is the default but does not make sense. "
"Please enter the domain where Mumble-Django is reachable." ); "Please enter the domain where Mumble-Django is reachable." );
site.domain = raw_input( "> " ).strip(); site.domain = raw_input( "> " ).strip();
site.save(); site.save();
else:
print site.domain, "[ OK ]";
print site.domain, "[ OK ]";
def check_admins( self ): def check_admins( self ):
@ -79,7 +96,7 @@ class Command( BaseCommand ):
mm = Mumble.objects.all(); mm = Mumble.objects.all();
if mm.count() == 0: if mm.count() == 0:
raise TestFailed( ""
raise TestFailed(
"no Mumble servers are configured, you might want to run " "no Mumble servers are configured, you might want to run "
"`./manage.py syncdb` to run an auto detection." ); "`./manage.py syncdb` to run an auto detection." );

Loading…
Cancel
Save