Browse Source

review verbosity levels to display messages in a sensible context

Natenom/support-murmur-13-1446181288462
Michael Ziegler 14 years ago
parent
commit
8a30578065
  1. 14
      pyweb/mumble/management/server_detect.py
  2. 23
      pyweb/mumble/management/update_schema.py
  3. 2
      pyweb/mumble/models.py

14
pyweb/mumble/management/server_detect.py

@ -115,18 +115,14 @@ def find_existing_instances( **kwargs ):
"srvid": id,
}
if v > 1:
print "Found new Murmur instance %d on bus '%s'... " % ( id, dbusName ),
if v:
print "Found new Murmur instance %d on bus '%s'... " % ( id, dbusName )
# now create a model for the record set.
instance = Mumble( **values );
else:
if v > 1:
print "Syncing Murmur instance... ",
if v > 1:
print instance.name;
if v:
print "Syncing Murmur instance %d: '%s'... " % ( instance.id, instance.name )
try:
instance.configureFromMurmur();
@ -163,7 +159,7 @@ def find_existing_instances( **kwargs ):
if v > 1:
print "Looking for registered Players on Server id %d." % id;
instance.readUsersFromMurmur( verbose=v );
elif v > 1:
elif v:
print "This server is not running, can't sync players.";
if v > 1:

23
pyweb/mumble/management/update_schema.py

@ -26,7 +26,15 @@ from mumble.management.server_detect import find_existing_instances
def update_schema( **kwargs ):
scriptpath = join(
if "verbosity" in kwargs:
v = kwargs['verbosity'];
else:
v = 1;
if v:
print "Migrating Database schema for Mumble-Django 2.0 now."
scriptdir = join(
settings.MUMBLE_DJANGO_ROOT, "pyweb", "mumble", "conversionsql", {
'postgresql_psycopg2': 'pgsql',
'postgresql': 'pgsql',
@ -35,14 +43,20 @@ def update_schema( **kwargs ):
}[settings.DATABASE_ENGINE]
)
scripts = [ filename for filename in os.listdir( scriptpath ) if filename.endswith( ".sql" ) ]
if v > 1:
print "Reading migration scripts for %s from '%s'" % ( settings.DATABASE_ENGINE, scriptdir )
scripts = [ filename for filename in os.listdir( scriptdir ) if filename.endswith( ".sql" ) ]
scripts.sort()
for filename in scripts:
cursor = connection.cursor()
scriptfile = open( os.path.join( scriptpath, filename ), "r" )
scriptpath = os.path.join( scriptdir, filename )
scriptfile = open( scriptpath, "r" )
try:
if v > 1:
print "Running migration script '%s'..." % scriptpath
stmt = scriptfile.read()
cursor.execute( stmt )
@ -58,4 +72,7 @@ def update_schema( **kwargs ):
scriptfile.close()
cursor.close()
if v:
print "Database migration finished successfully."
find_existing_instances( **kwargs )

2
pyweb/mumble/models.py

@ -328,7 +328,7 @@ class Mumble( models.Model ):
else:
if verbose > 1:
print "Player '%s' is already listed in the database." % playerdata.name;
print "Player '%s' is already known." % playerdata.name;
playerinstance = MumbleUser.objects.get( server=self, mumbleid=playerdata.userid );
playerinstance.name = playerdata.name;

Loading…
Cancel
Save