Browse Source

review verbosity levels to display messages in a sensible context

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 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, "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. # now create a model for the record set.
instance = Mumble( **values ); instance = Mumble( **values );
else: 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: try:
instance.configureFromMurmur(); instance.configureFromMurmur();
@ -163,7 +159,7 @@ def find_existing_instances( **kwargs ):
if v > 1: if v > 1:
print "Looking for registered Players on Server id %d." % id; print "Looking for registered Players on Server id %d." % id;
instance.readUsersFromMurmur( verbose=v ); instance.readUsersFromMurmur( verbose=v );
elif v > 1:
elif v:
print "This server is not running, can't sync players."; print "This server is not running, can't sync players.";
if v > 1: 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 ): 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", { settings.MUMBLE_DJANGO_ROOT, "pyweb", "mumble", "conversionsql", {
'postgresql_psycopg2': 'pgsql', 'postgresql_psycopg2': 'pgsql',
'postgresql': 'pgsql', 'postgresql': 'pgsql',
@ -35,14 +43,20 @@ def update_schema( **kwargs ):
}[settings.DATABASE_ENGINE] }[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() scripts.sort()
for filename in scripts: for filename in scripts:
cursor = connection.cursor() cursor = connection.cursor()
scriptfile = open( os.path.join( scriptpath, filename ), "r" )
scriptpath = os.path.join( scriptdir, filename )
scriptfile = open( scriptpath, "r" )
try: try:
if v > 1:
print "Running migration script '%s'..." % scriptpath
stmt = scriptfile.read() stmt = scriptfile.read()
cursor.execute( stmt ) cursor.execute( stmt )
@ -58,4 +72,7 @@ def update_schema( **kwargs ):
scriptfile.close() scriptfile.close()
cursor.close() cursor.close()
if v:
print "Database migration finished successfully."
find_existing_instances( **kwargs ) find_existing_instances( **kwargs )

2
pyweb/mumble/models.py

@ -328,7 +328,7 @@ class Mumble( models.Model ):
else: else:
if verbose > 1: 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 = MumbleUser.objects.get( server=self, mumbleid=playerdata.userid );
playerinstance.name = playerdata.name; playerinstance.name = playerdata.name;

Loading…
Cancel
Save