Browse Source

introduce slicefile parameter to get the CTL stuff independent from django.conf.settings

Natenom/support-murmur-13-1446181288462
Michael Ziegler 14 years ago
parent
commit
e336523df4
  1. 17
      pyweb/mumble/MumbleCtlIce.py
  2. 13
      pyweb/mumble/management/server_detect.py
  3. 4
      pyweb/mumble/mctl.py
  4. 2
      pyweb/mumble/models.py

17
pyweb/mumble/MumbleCtlIce.py

@ -20,8 +20,6 @@ from PIL import Image
from struct import pack, unpack
from zlib import compress, decompress
from django.conf import settings
from mctl import MumbleCtlBase
from utils import ObjectInfo
@ -44,13 +42,14 @@ def protectDjangoErrPage( func ):
return func( *args, **kwargs );
except Ice.Exception, e:
raise e;
protection_wrapper.innerfunc = func
return protection_wrapper;
@protectDjangoErrPage
def MumbleCtlIce( connstring ):
def MumbleCtlIce( connstring, slicefile ):
""" Choose the correct Ice handler to use (1.1.8 or 1.2.x), and make sure the
Murmur version matches the slice Version.
"""
@ -59,19 +58,19 @@ def MumbleCtlIce( connstring ):
import Murmur
except ImportError:
if not settings.SLICE:
if not slicefile:
raise EnvironmentError( "You didn't configure a slice file. Please set the SLICE variable in settings.py." )
if not exists( settings.SLICE ):
raise EnvironmentError( "The slice file does not exist: '%s' - please check the settings." % settings.SLICE )
if not exists( slicefile ):
raise EnvironmentError( "The slice file does not exist: '%s' - please check the settings." % slicefile )
if " " in settings.SLICE:
if " " in slicefile:
raise EnvironmentError( "You have a space char in your Slice path. This will confuse Ice, please check." )
if not settings.SLICE.endswith( ".ice" ):
if not slicefile.endswith( ".ice" ):
raise EnvironmentError( "The slice file name MUST end with '.ice'." )
Ice.loadSlice( settings.SLICE )
Ice.loadSlice( slicefile )
import Murmur

13
pyweb/mumble/management/server_detect.py

@ -16,8 +16,11 @@
import os
from mumble import models
from mumble.mctl import MumbleCtlBase
from django.conf import settings
from mumble import models
from mumble.mctl import MumbleCtlBase
def find_in_dicts( keys, conf, default, valueIfNotFound=None ):
if not isinstance( keys, tuple ):
@ -66,7 +69,9 @@ def find_existing_instances( **kwargs ):
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!';
print 'Be sure to run "python manage.py syncdb" with Murmur running before'
print "trying to use this app! Otherwise, existing Murmur servers won't be"
print 'configurable!';
return False;
elif dbusName == "1":
dbusName = "net.sourceforge.mumble.murmur";
@ -74,7 +79,7 @@ def find_existing_instances( **kwargs ):
dbusName = "Meta:tcp -h 127.0.0.1 -p 6502";
try:
ctl = MumbleCtlBase.newInstance( dbusName );
ctl = MumbleCtlBase.newInstance( dbusName, settings.SLICE );
except Exception, instance:
if v:
print "Unable to connect using name %s. The error was:" % dbusName;

4
pyweb/mumble/mctl.py

@ -95,7 +95,7 @@ class MumbleCtlBase (object):
raise NotImplementedError( "mctl::verifyPassword" );
@staticmethod
def newInstance( connstring ):
def newInstance( connstring, slicefile ):
""" Create a new CTL object for the given connstring. """
# check cache
@ -112,7 +112,7 @@ class MumbleCtlBase (object):
ctl = MumbleCtlDbus( connstring )
else:
from MumbleCtlIce import MumbleCtlIce
ctl = MumbleCtlIce( connstring )
ctl = MumbleCtlIce( connstring, slicefile )
MumbleCtlBase.cache[connstring] = ctl;
return ctl;

2
pyweb/mumble/models.py

@ -170,7 +170,7 @@ class Mumble( models.Model ):
Only one instance will be created, and reused on subsequent calls.
"""
if not self._ctl:
self._ctl = MumbleCtlBase.newInstance( self.dbus );
self._ctl = MumbleCtlBase.newInstance( self.dbus, settings.SLICE );
return self._ctl;
ctl = property( getCtl, doc="Get a Control object for this server. The ctl is cached for later reuse." );

Loading…
Cancel
Save