Browse Source

removed "DAOTYPE" setting (that's what the dbus field in the Mumble model is for), and added an automatic switch between the methods to MumbleCtlBase. repaired management.py.

Natenom/support-murmur-13-1446181288462
Michael Ziegler 16 years ago
parent
commit
1f67272b9b
  1. 6
      pyweb/mumble/MumbleCtlDbus.py
  2. 9
      pyweb/mumble/MumbleCtlIce.py
  3. 37
      pyweb/mumble/management.py
  4. 16
      pyweb/mumble/mctl.py
  5. 18
      pyweb/mumble/models.py
  6. 3
      pyweb/settings.py

6
pyweb/mumble/MumbleCtlDbus.py

@ -23,11 +23,11 @@ from mctl import MumbleCtlBase
import dbus import dbus
class MumbleCtlDbus(MumbleCtlBase): class MumbleCtlDbus(MumbleCtlBase):
meta = None
dbus_base='net.sourceforge.mumble.murmur'
method = "DBus";
def __init__(self):
def __init__( self, connstring ):
# Prior to saving the model, connect to murmur via dbus and update its settings. # Prior to saving the model, connect to murmur via dbus and update its settings.
self.dbus_base = connstring;
self.meta = self._getDbusMeta(); self.meta = self._getDbusMeta();
def _getDbusMeta( self ): def _getDbusMeta( self ):

9
pyweb/mumble/MumbleCtlIce.py

@ -26,15 +26,14 @@ from mctl import MumbleCtlBase
import Ice import Ice
class MumbleCtlIce(MumbleCtlBase): class MumbleCtlIce(MumbleCtlBase):
proxy = 'Meta:tcp -h 127.0.0.1 -p 6502'
slice = settings.SLICE
meta = None
method = "ICE";
def __init__(self):
def __init__( self, connstring ):
self.proxy = connstring;
self.meta = self._getIceMeta() self.meta = self._getIceMeta()
def _getIceMeta(self): def _getIceMeta(self):
Ice.loadSlice(self.slice)
Ice.loadSlice(settings.SLICE)
ice = Ice.initialize() ice = Ice.initialize()
import Murmur import Murmur
prx = ice.stringToProxy(self.proxy) prx = ice.stringToProxy(self.proxy)

37
pyweb/mumble/management.py

@ -37,8 +37,6 @@ def find_in_dicts( keys, conf, default, valueIfNotFound=None ):
def find_existing_instances( **kwargs ): def find_existing_instances( **kwargs ):
ctl = MumbleCtlBase.newInstance();
if "verbosity" in kwargs: if "verbosity" in kwargs:
v = kwargs['verbosity']; v = kwargs['verbosity'];
else: else:
@ -47,24 +45,41 @@ def find_existing_instances( **kwargs ):
if v > 1: if v > 1:
print "Starting Mumble servers and players detection now."; print "Starting Mumble servers and players detection now.";
'''
online = False; online = False;
while not online: while not online:
try:
murmur = dbus.Interface( bus.get_object( dbusName, '/' ), 'net.sourceforge.mumble.Meta' );
except dbus.exceptions.DBusException:
if v:
print "Unable to connect to DBus using name %s. Is Murmur even running!?" % dbusName;
dbusName = raw_input( "DBus Service name (or empty to skip Servers/Players detection): " );
print
print "--- Murmur connection info ---"
print " 1) DBus -- net.sourceforge.mumble.murmur"
print " 2) ICE -- Meta:tcp -h 127.0.0.1 -p 6502"
print "Enter 1 or 2 for the defaults above, nothing to skip Server detection,"
print "and if the defaults do not fit your needs, enter the correct string."
print "Whether to use DBus or ICE will be detected automatically from the"
print "string's format."
print
dbusName = raw_input( "Service string: " );
if not dbusName: if not dbusName:
if v: if v:
print 'Be sure to run "python manage.py syncdb" with Murmur running before trying to use this app! Otherwise, existing Murmur servers won\'t be configurable!'; print 'Be sure to run "python manage.py syncdb" with Murmur running before trying to use this app! Otherwise, existing Murmur servers won\'t be configurable!';
return False; return False;
elif dbusName == "1":
dbusName = "net.sourceforge.mumble.murmur";
elif dbusName == "2":
dbusName = "Meta:tcp -h 127.0.0.1 -p 6502";
try:
ctl = MumbleCtlBase.newInstance( dbusName );
except Exception, instance:
if v:
print "Unable to connect using name %s. The error was:" % dbusName;
print instance;
else: else:
online = True; online = True;
if v > 1: if v > 1:
print "Successfully connected to Murmur via DBus (%s)." % dbusName;
'''
print "Successfully connected to Murmur via connection string %s, using %s." % ( dbusName, ctl.method );
default = ctl.getDefaultConf(); default = ctl.getDefaultConf();
servIDs = ctl.getAllServers(); servIDs = ctl.getAllServers();

16
pyweb/mumble/mctl.py

@ -19,7 +19,7 @@
#abc is better but 2.6 higher. #abc is better but 2.6 higher.
#import abc #import abc
from django.conf import settings
import re
class MumbleCtlBase (): class MumbleCtlBase ():
''' abstract Ctrol Object ''' ''' abstract Ctrol Object '''
@ -94,14 +94,18 @@ class MumbleCtlBase ():
pass pass
@staticmethod @staticmethod
def newInstance():
# if dbus
if settings.DAOTYPE == 'dbus':
def newInstance( connstring ):
# connstring defines whether to connect via ICE or DBus.
# Dbus service names: some.words.divided.by.periods
# ICE specs are WAY more complex, so if DBus doesn't match, use ICE.
rd = re.compile( r'^(\w+\.)*\w+$' );
if rd.match( connstring ):
from MumbleCtlDbus import MumbleCtlDbus from MumbleCtlDbus import MumbleCtlDbus
return MumbleCtlDbus()
return MumbleCtlDbus( connstring )
else: else:
from MumbleCtlIce import MumbleCtlIce from MumbleCtlIce import MumbleCtlIce
return MumbleCtlIce()
return MumbleCtlIce( connstring )

18
pyweb/mumble/models.py

@ -50,7 +50,7 @@ class Mumble( models.Model ):
booted = models.BooleanField( 'Boot Server', default = True ); booted = models.BooleanField( 'Boot Server', default = True );
def getServerObject( self ): def getServerObject( self ):
return mmServer( self.srvid, MumbleCtlBase.newInstance(), self.name );
return mmServer( self.srvid, MumbleCtlBase.newInstance( self.dbus ), self.name );
def __unicode__( self ): def __unicode__( self ):
return u'Murmur "%s" (%d)' % ( self.name, self.srvid ); return u'Murmur "%s" (%d)' % ( self.name, self.srvid );
@ -62,7 +62,7 @@ class Mumble( models.Model ):
# check if this server already exists, if not call newServer and set my srvid first # check if this server already exists, if not call newServer and set my srvid first
ctl = MumbleCtlBase.newInstance();
ctl = MumbleCtlBase.newInstance( self.dbus );
if self.id is None: if self.id is None:
self.srvid = ctl.newServer(); self.srvid = ctl.newServer();
@ -124,7 +124,7 @@ class Mumble( models.Model ):
def deleteServer( self ): def deleteServer( self ):
# Unregister this player in Murmur via ctroller. # Unregister this player in Murmur via ctroller.
#print MumbleCtlBase.newInstance() #print MumbleCtlBase.newInstance()
MumbleCtlBase.newInstance().deleteServer(self.srvid)
MumbleCtlBase.newInstance( self.dbus ).deleteServer(self.srvid)
@staticmethod @staticmethod
def pre_delete_listener( **kwargs ): def pre_delete_listener( **kwargs ):
@ -147,7 +147,7 @@ class MumbleUser( models.Model ):
return models.Model.save( self ); return models.Model.save( self );
# Before the record set is saved, update Murmur via ctroller. # Before the record set is saved, update Murmur via ctroller.
ctl = MumbleCtlBase.newInstance();
ctl = MumbleCtlBase.newInstance( self.server.dbus );
if self.id is None: if self.id is None:
# This is a new user record, so Murmur doesn't know about it yet # This is a new user record, so Murmur doesn't know about it yet
@ -179,7 +179,7 @@ class MumbleUser( models.Model ):
def getAdmin( self ): def getAdmin( self ):
# Get ACL of root Channel, get the admin group and see if I'm in it # Get ACL of root Channel, get the admin group and see if I'm in it
acl = mmACL( 0, MumbleCtlBase.newInstance().getACL(self.server.srvid, 0) );
acl = mmACL( 0, MumbleCtlBase.newInstance( self.server.dbus ).getACL(self.server.srvid, 0) );
if not hasattr( acl, "admingroup" ): if not hasattr( acl, "admingroup" ):
raise ValueError( "The admin group was not found in the ACL's groups list!" ); raise ValueError( "The admin group was not found in the ACL's groups list!" );
@ -187,7 +187,7 @@ class MumbleUser( models.Model ):
def setAdmin( self, value ): def setAdmin( self, value ):
# Get ACL of root Channel, get the admin group and see if I'm in it # Get ACL of root Channel, get the admin group and see if I'm in it
ctl = MumbleCtlBase.newInstance();
ctl = MumbleCtlBase.newInstance( self.server.dbus );
acl = mmACL( 0, ctl.getACL(self.server.srvid, 0) ); acl = mmACL( 0, ctl.getACL(self.server.srvid, 0) );
if not hasattr( acl, "admingroup" ): if not hasattr( acl, "admingroup" ):
@ -203,10 +203,10 @@ class MumbleUser( models.Model ):
return value; return value;
def getTexture( self ): def getTexture( self ):
return MumbleCtlBase.newInstance().getTexture(self.server.srvid, self.mumbleid);
return MumbleCtlBase.newInstance( self.server.dbus ).getTexture(self.server.srvid, self.mumbleid);
def setTexture( self, infile ): def setTexture( self, infile ):
MumbleCtlBase.newInstance().setTexture(self.server.srvid, self.mumbleid, infile)
MumbleCtlBase.newInstance( self.server.dbus ).setTexture(self.server.srvid, self.mumbleid, infile)
@staticmethod @staticmethod
def pre_delete_listener( **kwargs ): def pre_delete_listener( **kwargs ):
@ -214,7 +214,7 @@ class MumbleUser( models.Model ):
def unregister( self ): def unregister( self ):
# Unregister this player in Murmur via dbus. # Unregister this player in Murmur via dbus.
MumbleCtlBase.newInstance().unregisterPlayer(self.server.srvid, self.mumbleid)
MumbleCtlBase.newInstance( self.server.dbus ).unregisterPlayer(self.server.srvid, self.mumbleid)
def __setattr__( self, name, value ): def __setattr__( self, name, value ):
if name == 'server': if name == 'server':

3
pyweb/settings.py

@ -56,13 +56,12 @@ if not MUMBLE_DJANGO_ROOT or not exists( MUMBLE_DJANGO_ROOT ):
DEBUG = True DEBUG = True
TEMPLATE_DEBUG = DEBUG TEMPLATE_DEBUG = DEBUG
# The slice to use for communication over ZeroC ICE. # The slice to use for communication over ZeroC ICE.
# This can be set to the path to the Murmur.ice file that resides # This can be set to the path to the Murmur.ice file that resides
# in your Murmur directory. # in your Murmur directory.
SLICE = join( MUMBLE_DJANGO_ROOT, 'pyweb', 'mumble', 'Murmur.ice' ) SLICE = join( MUMBLE_DJANGO_ROOT, 'pyweb', 'mumble', 'Murmur.ice' )
DAOTYPE='ice'
#DAOTYPE='dbus'
ADMINS = ( ADMINS = (
# ('Your Name', 'your_email@domain.com'), # ('Your Name', 'your_email@domain.com'),

Loading…
Cancel
Save