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. 8
      pyweb/mumble/MumbleCtlDbus.py
  2. 13
      pyweb/mumble/MumbleCtlIce.py
  3. 41
      pyweb/mumble/management.py
  4. 18
      pyweb/mumble/mctl.py
  5. 18
      pyweb/mumble/models.py
  6. 3
      pyweb/settings.py

8
pyweb/mumble/MumbleCtlDbus.py

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

13
pyweb/mumble/MumbleCtlIce.py

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

41
pyweb/mumble/management.py

@ -37,8 +37,6 @@ def find_in_dicts( keys, conf, default, valueIfNotFound=None ):
def find_existing_instances( **kwargs ):
ctl = MumbleCtlBase.newInstance();
if "verbosity" in kwargs:
v = kwargs['verbosity'];
else:
@ -47,24 +45,41 @@ def find_existing_instances( **kwargs ):
if v > 1:
print "Starting Mumble servers and players detection now.";
'''
online = False;
while not online:
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 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!';
return False;
elif dbusName == "1":
dbusName = "net.sourceforge.mumble.murmur";
elif dbusName == "2":
dbusName = "Meta:tcp -h 127.0.0.1 -p 6502";
try:
murmur = dbus.Interface( bus.get_object( dbusName, '/' ), 'net.sourceforge.mumble.Meta' );
except dbus.exceptions.DBusException:
ctl = MumbleCtlBase.newInstance( dbusName );
except Exception, instance:
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): " );
if not dbusName:
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!';
return False;
print "Unable to connect using name %s. The error was:" % dbusName;
print instance;
else:
online = True;
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();
servIDs = ctl.getAllServers();

18
pyweb/mumble/mctl.py

@ -19,11 +19,11 @@
#abc is better but 2.6 higher.
#import abc
from django.conf import settings
import re
class MumbleCtlBase ():
''' abstract Ctrol Object '''
def getAllConf(self, srvid):
pass
@ -94,14 +94,18 @@ class MumbleCtlBase ():
pass
@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
return MumbleCtlDbus()
return MumbleCtlDbus( connstring )
else:
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 );
def getServerObject( self ):
return mmServer( self.srvid, MumbleCtlBase.newInstance(), self.name );
return mmServer( self.srvid, MumbleCtlBase.newInstance( self.dbus ), self.name );
def __unicode__( self ):
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
ctl = MumbleCtlBase.newInstance();
ctl = MumbleCtlBase.newInstance( self.dbus );
if self.id is None:
self.srvid = ctl.newServer();
@ -124,7 +124,7 @@ class Mumble( models.Model ):
def deleteServer( self ):
# Unregister this player in Murmur via ctroller.
#print MumbleCtlBase.newInstance()
MumbleCtlBase.newInstance().deleteServer(self.srvid)
MumbleCtlBase.newInstance( self.dbus ).deleteServer(self.srvid)
@staticmethod
def pre_delete_listener( **kwargs ):
@ -147,7 +147,7 @@ class MumbleUser( models.Model ):
return models.Model.save( self );
# Before the record set is saved, update Murmur via ctroller.
ctl = MumbleCtlBase.newInstance();
ctl = MumbleCtlBase.newInstance( self.server.dbus );
if self.id is None:
# 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 ):
# 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" ):
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 ):
# 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) );
if not hasattr( acl, "admingroup" ):
@ -203,10 +203,10 @@ class MumbleUser( models.Model ):
return value;
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 ):
MumbleCtlBase.newInstance().setTexture(self.server.srvid, self.mumbleid, infile)
MumbleCtlBase.newInstance( self.server.dbus ).setTexture(self.server.srvid, self.mumbleid, infile)
@staticmethod
def pre_delete_listener( **kwargs ):
@ -214,7 +214,7 @@ class MumbleUser( models.Model ):
def unregister( self ):
# 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 ):
if name == 'server':

3
pyweb/settings.py

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

Loading…
Cancel
Save