Browse Source

Now players are being entered into the DB as well.

Natenom/support-murmur-13-1446181288462
work 16 years ago
parent
commit
74741c380f
  1. 32
      pyweb/mumble/management.py
  2. 2
      pyweb/mumble/models.py

32
pyweb/mumble/management.py

@ -52,8 +52,6 @@ def find_in_dicts( keys, conf, default, valueIfNotFound=None ):
def find_existing_instances( **kwargs ):
print "Searching DBus for existing murmur instances. Hope Murmur is running.";
bus = dbus.SystemBus();
murmur = dbus.Interface( bus.get_object( 'net.sourceforge.mumble.murmur', '/' ), 'net.sourceforge.mumble.Meta');
@ -63,6 +61,10 @@ def find_existing_instances( **kwargs ):
bootedIDs = murmur.getBootedServers();
for id in servIDs:
# first check that the server has not yet been inserted into the DB
try:
instance = models.Mumble.objects.get( srvid=id );
except models.Mumble.DoesNotExist:
conf = murmur.getAllConf( dbus.Int32( id ) );
# We need at least:
# name srvid addr
@ -94,6 +96,32 @@ def find_existing_instances( **kwargs ):
instance = models.Mumble( **values );
instance.save( dontConfigureMurmur=True );
# Now search for players on this server that have not yet been registered
if id in bootedIDs:
murmurinstance = dbus.Interface(
bus.get_object( 'net.sourceforge.mumble.murmur', '/%d'%id ),
'net.sourceforge.mumble.Murmur'
);
players = murmurinstance.getRegisteredPlayers('');
for playerdata in players:
if playerdata[0] == 0:
continue;
try:
models.MumbleUser.objects.get( mumbleid=playerdata[0] );
except models.MumbleUser.DoesNotExist:
print 'Found Player "%s"' % playerdata[1];
playerinstance = models.MumbleUser(
mumbleid = playerdata[0],
name = playerdata[1],
password = '',
server = instance,
owner = None
);
playerinstance.save( dontConfigureMurmur=True );
signals.post_syncdb.connect( find_existing_instances, sender=models );

2
pyweb/mumble/models.py

@ -149,7 +149,7 @@ class MumbleUser( models.Model ):
name = models.CharField( 'User name and Login', max_length = 200 );
password = models.CharField( 'Login password', max_length = 200 );
server = models.ForeignKey( Mumble );
owner = models.ForeignKey( User );
owner = models.ForeignKey( User, null=True, blank=True );
def __unicode__( self ):
return u"Mumble user %s on %s owned by Django user %s" % ( self.name, self.server, self.owner );

Loading…
Cancel
Save