Browse Source

Bugfix: ProxyObject used from dbus.proxies module

Natenom/support-murmur-13-1446181288462
root 16 years ago
parent
commit
1b9ee60ebd
  1. 18
      pyweb/mumble/mmobjects.py

18
pyweb/mumble/mmobjects.py

@ -35,6 +35,7 @@ import dbus
import datetime import datetime
from time import time from time import time
# base = ice.stringToProxy( "Meta:tcp -h 127.0.0.1 -p 6502" ); # base = ice.stringToProxy( "Meta:tcp -h 127.0.0.1 -p 6502" );
# srv = Murmur.ServerPrx.checkedCast( base ); # srv = Murmur.ServerPrx.checkedCast( base );
# met = Murmur.MetaPrx.checkedCast( base ); # met = Murmur.MetaPrx.checkedCast( base );
@ -46,7 +47,7 @@ class mmServer( object ):
# rootName = str(); # rootName = str();
def __init__( self, serverID, serverObj, rootName = '' ): def __init__( self, serverID, serverObj, rootName = '' ):
if not isinstance( serverObj, dbus.ProxyObject ):
if not isinstance( serverObj, dbus.proxies.ProxyObject ):
raise Exception, "mmServer: I need the object returned by dbus.get_object!" raise Exception, "mmServer: I need the object returned by dbus.get_object!"
self.dbusObj = serverObj; self.dbusObj = serverObj;
@ -66,6 +67,8 @@ class mmServer( object ):
else: else:
self.channels[theChan[0]] = mmChannel( theChan, self.channels[theChan[2]] ); self.channels[theChan[0]] = mmChannel( theChan, self.channels[theChan[2]] );
self.channels[theChan[0]].serverId = self.id;
# process links - if the linked channels are known, link; else save their ids to link later # process links - if the linked channels are known, link; else save their ids to link later
for linked in theChan[3]: for linked in theChan[3]:
if linked in self.channels: if linked in self.channels:
@ -132,6 +135,7 @@ class mmChannel( object ):
self.parent = parentChan; self.parent = parentChan;
if self.parent is not None: if self.parent is not None:
self.parent.subchans.append( self ); self.parent.subchans.append( self );
self.serverId = self.parent.serverId;
def parentChannels( self ): def parentChannels( self ):
if self.parent is None or self.parent.is_server() or self.parent.id == 0: if self.parent is None or self.parent.is_server() or self.parent.id == 0:
@ -177,12 +181,24 @@ class mmPlayer( object ):
# onlinesince = time(); # onlinesince = time();
# bytesPerSec = int(); # bytesPerSec = int();
# mumbleuser = models.MumbleUser();
def __init__( self, playerObj, playerChan ): def __init__( self, playerObj, playerChan ):
( self.userid, self.muted, self.deafened, self.suppressed, self.selfmuted, self.selfdeafened, chanID, self.dbaseid, self.name, onlinetime, self.bytesPerSec ) = playerObj; ( self.userid, self.muted, self.deafened, self.suppressed, self.selfmuted, self.selfdeafened, chanID, self.dbaseid, self.name, onlinetime, self.bytesPerSec ) = playerObj;
self.onlinesince = datetime.datetime.fromtimestamp( float( time() - onlinetime ) ); self.onlinesince = datetime.datetime.fromtimestamp( float( time() - onlinetime ) );
self.channel = playerChan; self.channel = playerChan;
self.channel.players.append( self ); self.channel.players.append( self );
if self.isAuthed():
from models import Mumble, MumbleUser
srvInstance = Mumble.objects.get( srvid=self.channel.serverId );
try:
self.mumbleuser = MumbleUser.objects.get( mumbleid=self.dbaseid, server=srvInstance );
except MumbleUser.DoesNotExist:
self.mumbleuser = None;
else:
self.mumbleuser = None;
def __str__( self ): def __str__( self ):
return '<Player "%s" (%d, %d)>' % ( self.name, self.userid, self.dbaseid ); return '<Player "%s" (%d, %d)>' % ( self.name, self.userid, self.dbaseid );

Loading…
Cancel
Save