|
|
@ -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 ); |
|
|
|
|
|
|
|