Browse Source

removed dysfunctional unit tests and changed raised exceptions to better fitting class names

Natenom/support-murmur-13-1446181288462
Michael Ziegler 16 years ago
parent
commit
0e2f58c35e
  1. 9
      pyweb/mumble/MumbleCtlDbus.py
  2. 27
      pyweb/mumble/mctl.py
  3. 7
      pyweb/mumble/models.py

9
pyweb/mumble/MumbleCtlDbus.py

@ -22,11 +22,11 @@ from zlib import compress, decompress
from mctl import MumbleCtlBase from mctl import MumbleCtlBase
import dbus import dbus
class MumbleCtlDbus(MumbleCtlBase): class MumbleCtlDbus(MumbleCtlBase):
method = "DBus"; method = "DBus";
def __init__( self, connstring ): def __init__( self, connstring ):
# Prior to saving the model, connect to murmur via dbus and update its settings.
self.dbus_base = connstring; self.dbus_base = connstring;
self.meta = self._getDbusMeta(); self.meta = self._getDbusMeta();
@ -34,10 +34,8 @@ class MumbleCtlDbus(MumbleCtlBase):
return dbus.Interface( dbus.SystemBus().get_object( self.dbus_base, '/' ), 'net.sourceforge.mumble.Meta' ); return dbus.Interface( dbus.SystemBus().get_object( self.dbus_base, '/' ), 'net.sourceforge.mumble.Meta' );
def _getDbusServerObject( self, srvid): def _getDbusServerObject( self, srvid):
"Connects to DBus and returns an mmServer object representing this Murmur instance."
if srvid not in self.getBootedServers(): if srvid not in self.getBootedServers():
raise Exception, 'No murmur process with the given server ID (%d) is running and attached to system dbus under %s.' % ( srvid, self.meta );
raise SystemError, 'No murmur process with the given server ID (%d) is running and attached to system dbus under %s.' % ( srvid, self.meta );
return dbus.Interface( dbus.SystemBus().get_object( self.dbus_base, '/%d' % srvid ), 'net.sourceforge.mumble.Murmur' ); return dbus.Interface( dbus.SystemBus().get_object( self.dbus_base, '/%d' % srvid ), 'net.sourceforge.mumble.Murmur' );
@ -104,7 +102,6 @@ class MumbleCtlDbus(MumbleCtlBase):
def setRegistration(self, srvid, mumbleid, name, email, password): def setRegistration(self, srvid, mumbleid, name, email, password):
return MumbleCtlDbus.converDbusTypeToNative(self._getDbusServerObject(srvid).setRegistration(dbus.Int32(mumbleid), name, email, password)) return MumbleCtlDbus.converDbusTypeToNative(self._getDbusServerObject(srvid).setRegistration(dbus.Int32(mumbleid), name, email, password))
#return MumbleCtlDbus.converDbusTypeToNative(self._getDbusServerObject(srvid).setRegistration(dbus.Int32(mumbleid), dbus.String(name), dbus.String(email), dbus.String(password)))
def getTexture(self, srvid, mumbleid): def getTexture(self, srvid, mumbleid):
texture = self._getDbusServerObject(srvid).getTexture(dbus.Int32(mumbleid)); texture = self._getDbusServerObject(srvid).getTexture(dbus.Int32(mumbleid));
@ -170,3 +167,5 @@ class MumbleCtlDbus(MumbleCtlBase):
elif data.__class__ is dbus.Byte: elif data.__class__ is dbus.Byte:
ret = byte(data) ret = byte(data)
return ret return ret

27
pyweb/mumble/mctl.py

@ -15,10 +15,6 @@
* GNU General Public License for more details. * GNU General Public License for more details.
""" """
#zope.interface is good but don't standard interface library
#abc is better but 2.6 higher.
#import abc
import re import re
class MumbleCtlBase (): class MumbleCtlBase ():
@ -106,26 +102,3 @@ class MumbleCtlBase ():
if __name__ == "__main__":
import sys
from MumbleCtlIce import MumbleCtlIce
from MumbleCtlDbus import MumbleCtlDbus
x = int(sys.argv[1])
dbusCtl = MumbleCtlDbus()
iceCtl = MumbleCtlIce()
print "equal test ---"
print "getBootedServers [%s]" % (dbusCtl.getBootedServers() == iceCtl.getBootedServers())
print "getChannels [%s]" % (dbusCtl.getChannels(x) == iceCtl.getChannels(x))
print "getPlayers [%s]" % (dbusCtl.getPlayers(x) == iceCtl.getPlayers(x))
print "getACL(x, 0) [%s]" % (dbusCtl.getACL(x, 0) == iceCtl.getACL(x, 0))
print "getAllServers [%s]" % (dbusCtl.getAllServers() == iceCtl.getAllServers())
print "getDefaultConf [%s]" % (dbusCtl.getDefaultConf() == iceCtl.getDefaultConf())
print "getAllConf(x) [%s]" % (dbusCtl.getAllConf(x) == iceCtl.getAllConf(x))
print dbusCtl.getRegisteredPlayers(x)
#print dbusCtl.getRegisteredPlayers(x)[3][1]
print iceCtl.getRegisteredPlayers(x)
#print iceCtl.getRegisteredPlayers(x)[3][1]
print "getRegisteredPlayers(x) [%s]" % (dbusCtl.getRegisteredPlayers(x) == iceCtl.getRegisteredPlayers(x))
#print "getTexture(2, 30) [%s]" % (dbusCtl.getTexture(2, 30) == iceCtl.getTexture(2, 30))
#print dbusCtl.getTexture(2, 30).__class__

7
pyweb/mumble/models.py

@ -144,7 +144,6 @@ class Mumble( models.Model ):
# Deletion handler # Deletion handler
def deleteServer( self ): def deleteServer( self ):
# Unregister this player in Murmur via ctroller.
self.ctl.deleteServer(self.srvid) self.ctl.deleteServer(self.srvid)
@staticmethod @staticmethod
@ -152,7 +151,7 @@ class Mumble( models.Model ):
kwargs['instance'].deleteServer(); kwargs['instance'].deleteServer();
# Channel lists: flat list
# Channel list
def getChannels( self ): def getChannels( self ):
if self._channels is None: if self._channels is None:
self._channels = {}; self._channels = {};
@ -291,7 +290,7 @@ class MumbleUser( models.Model ):
acl = mmACL( 0, self.server.ctl.getACL(self.server.srvid, 0) ); acl = mmACL( 0, self.server.ctl.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 ReferenceError( "The admin group was not found in the ACL's groups list!" );
return self.mumbleid in acl.admingroup['add']; return self.mumbleid in acl.admingroup['add'];
def setAdmin( self, value ): def setAdmin( self, value ):
@ -300,7 +299,7 @@ class MumbleUser( models.Model ):
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" ):
raise ValueError( "The admin group was not found in the ACL's groups list!" );
raise ReferenceError( "The admin group was not found in the ACL's groups list!" );
if value != ( self.mumbleid in acl.admingroup['add'] ): if value != ( self.mumbleid in acl.admingroup['add'] ):
if value: if value:

Loading…
Cancel
Save