Forked mumble-django project from https://bitbucket.org/Svedrin/mumble-django
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
4.4 KiB

  1. # -*- coding: utf-8 -*-
  2. """
  3. * Copyright (C) 2009, withgod <withgod@sourceforge.net>
  4. * Michael "Svedrin" Ziegler <diese-addy@funzt-halt.net>
  5. *
  6. * Mumble-Django is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This package is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. """
  16. #zope.interface is good but don't standard interface library
  17. #abc is better but 2.6 higher.
  18. #import abc
  19. import re
  20. class MumbleCtlBase ():
  21. ''' abstract Ctrol Object '''
  22. def getAllConf(self, srvid):
  23. raise NotImplementedError( "mctl::getAllConf" );
  24. def getVersion( self ):
  25. raise NotImplementedError( "mctl::getVersion );
  26. def setConf(self, srvid, key, value):
  27. raise NotImplementedError( "mctl::setConf" );
  28. def getDefaultConf(self):
  29. raise NotImplementedError( "mctl::getDefaultConf" );
  30. def newServer(self):
  31. raise NotImplementedError( "mctl::newServer" );
  32. def setSuperUserPassword(self, srvid, value):
  33. raise NotImplementedError( "mctl::setSuperUserPassword" );
  34. def start(self, srvid):
  35. raise NotImplementedError( "mctl::start" );
  36. def stop(self, srvid):
  37. raise NotImplementedError( "mctl::stop" );
  38. def isBooted(self, srvid):
  39. raise NotImplementedError( "mctl::isBooted" );
  40. def deleteServer(self, srvid):
  41. raise NotImplementedError( "mctl::deleteServer" );
  42. def getPlayers(self, srvid):
  43. raise NotImplementedError( "mctl::getPlayers" );
  44. def getRegisteredPlayers(self, srvid, filter):
  45. raise NotImplementedError( "mctl::getRegisteredPlayers" );
  46. def getChannels(self, srvid):
  47. raise NotImplementedError( "mctl::getChannels" );
  48. def registerPlayer(self, srvid, name):
  49. raise NotImplementedError( "mctl::registerPlayer" );
  50. def setRegistration(self, srvid, mumbleid, name, email, password):
  51. raise NotImplementedError( "mctl::setRegistration" );
  52. def unregisterPlayer(self, srvid, mumbleid):
  53. raise NotImplementedError( "mctl::unregisterPlayer" );
  54. def getBootedServers(self):
  55. raise NotImplementedError( "mctl::getBootedServers" );
  56. def getAllServers(self):
  57. raise NotImplementedError( "mctl::getAllServers" );
  58. def getACL(self, srvid, identifier):
  59. raise NotImplementedError( "mctl::getACL" );
  60. def setACL(self, srvid, acl):
  61. raise NotImplementedError( "mctl::setACL" );
  62. def getTexture(self, srvid, mumbleid):
  63. raise NotImplementedError( "mctl::getTexture" );
  64. def setTexture(self, srvid, mumbleid, infile):
  65. raise NotImplementedError( "mctl::setTexture" );
  66. @staticmethod
  67. def newInstance( connstring ):
  68. # connstring defines whether to connect via ICE or DBus.
  69. # Dbus service names: some.words.divided.by.periods
  70. # ICE specs are WAY more complex, so if DBus doesn't match, use ICE.
  71. rd = re.compile( r'^(\w+\.)*\w+$' );
  72. if rd.match( connstring ):
  73. from MumbleCtlDbus import MumbleCtlDbus
  74. return MumbleCtlDbus( connstring )
  75. else:
  76. from MumbleCtlIce import MumbleCtlIce
  77. return MumbleCtlIce( connstring )
  78. if __name__ == "__main__":
  79. import sys
  80. from MumbleCtlIce import MumbleCtlIce
  81. from MumbleCtlDbus import MumbleCtlDbus
  82. x = int(sys.argv[1])
  83. dbusCtl = MumbleCtlDbus()
  84. iceCtl = MumbleCtlIce()
  85. print "equal test ---"
  86. print "getBootedServers [%s]" % (dbusCtl.getBootedServers() == iceCtl.getBootedServers())
  87. print "getChannels [%s]" % (dbusCtl.getChannels(x) == iceCtl.getChannels(x))
  88. print "getPlayers [%s]" % (dbusCtl.getPlayers(x) == iceCtl.getPlayers(x))
  89. print "getACL(x, 0) [%s]" % (dbusCtl.getACL(x, 0) == iceCtl.getACL(x, 0))
  90. print "getAllServers [%s]" % (dbusCtl.getAllServers() == iceCtl.getAllServers())
  91. print "getDefaultConf [%s]" % (dbusCtl.getDefaultConf() == iceCtl.getDefaultConf())
  92. print "getAllConf(x) [%s]" % (dbusCtl.getAllConf(x) == iceCtl.getAllConf(x))
  93. print dbusCtl.getRegisteredPlayers(x)
  94. #print dbusCtl.getRegisteredPlayers(x)[3][1]
  95. print iceCtl.getRegisteredPlayers(x)
  96. #print iceCtl.getRegisteredPlayers(x)[3][1]
  97. print "getRegisteredPlayers(x) [%s]" % (dbusCtl.getRegisteredPlayers(x) == iceCtl.getRegisteredPlayers(x))
  98. #print "getTexture(2, 30) [%s]" % (dbusCtl.getTexture(2, 30) == iceCtl.getTexture(2, 30))
  99. #print dbusCtl.getTexture(2, 30).__class__