From 0f79e664cb377880366ecb54d0b2ee712ce3bfc0 Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Fri, 26 Feb 2010 19:14:43 +0100 Subject: [PATCH] add getslice management command that checks if the slice can be fetched using getSlice. --- pyweb/mumble/management/commands/checkenv.py | 2 + pyweb/mumble/management/commands/getslice.py | 56 ++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 pyweb/mumble/management/commands/getslice.py diff --git a/pyweb/mumble/management/commands/checkenv.py b/pyweb/mumble/management/commands/checkenv.py index 6468d63..c65baf4 100644 --- a/pyweb/mumble/management/commands/checkenv.py +++ b/pyweb/mumble/management/commands/checkenv.py @@ -28,6 +28,8 @@ class TestFailed( Exception ): pass; class Command( BaseCommand ): + help = "Run a few tests on Mumble-Django's setup." + def handle(self, **options): try: import Ice diff --git a/pyweb/mumble/management/commands/getslice.py b/pyweb/mumble/management/commands/getslice.py new file mode 100644 index 0000000..1de8b05 --- /dev/null +++ b/pyweb/mumble/management/commands/getslice.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- + +""" + * Copyright © 2009-2010, Michael "Svedrin" Ziegler + * + * Mumble-Django is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. +""" + +import Ice, IcePy, os, getpass +from sys import stderr + +from django.core.management.base import BaseCommand + +from mumble.models import MumbleServer + +class Command( BaseCommand ): + help = "Check if the known servers support getSlice." + + def handle(self, **options): + prop = Ice.createProperties([]) + prop.setProperty("Ice.ImplicitContext", "Shared") + + idd = Ice.InitializationData() + idd.properties = prop + + ice = Ice.initialize(idd) + + for serv in MumbleServer.objects.all(): + print "Probing server at '%s'..." % serv.dbus + + if serv.secret: + ice.getImplicitContext().put( "secret", serv.secret.encode("utf-8") ) + + prx = ice.stringToProxy( serv.dbus.encode("utf-8") ) + + # Try loading the Slice from Murmur directly via its getSlice method. + try: + slice = IcePy.Operation( 'getSlice', + Ice.OperationMode.Idempotent, Ice.OperationMode.Idempotent, + True, (), (), (), IcePy._t_string, () + ).invoke(prx, ((), None)) + except TypeError, err: + print " Received TypeError:", err + print " It seems your version of IcePy is incompatible." + except Ice.OperationNotExistException: + print " Your version of Murmur does not support getSlice." + else: + print " Successfully received the slice (length: %d bytes.)" % len(slice)