Browse Source

a bunch'a cleanups to fix pyflakes warnings (and a few so far undiscovered bugs as well...)

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
c16d62d07e
  1. 4
      pyweb/mumble/MumbleCtlDbus.py
  2. 2
      pyweb/mumble/admin.py
  3. 3
      pyweb/mumble/forms.py
  4. 2
      pyweb/mumble/management/commands/checkenv.py
  5. 2
      pyweb/mumble/management/server_detect.py
  6. 4
      pyweb/mumble/mmobjects.py
  7. 37
      pyweb/mumble/models.py
  8. 4
      pyweb/mumble/murmurenvutils.py
  9. 5
      pyweb/mumble/tests.py
  10. 2
      pyweb/mumble/urls.py
  11. 21
      pyweb/mumble/views.py
  12. 2
      pyweb/urls.py
  13. 13
      pyweb/views.py

4
pyweb/mumble/MumbleCtlDbus.py

@ -32,7 +32,7 @@ def MumbleCtlDbus( connstring ):
meta = dbus.Interface( dbus.SystemBus().get_object( connstring, '/' ), 'net.sourceforge.mumble.Meta' );
try:
version = meta.getVersion();
meta.getVersion();
except DBusException:
return MumbleCtlDbus_Legacy( connstring, meta );
else:
@ -306,7 +306,7 @@ class MumbleCtlDbus_118(MumbleCtlBase):
elif data.__class__ is dbus.Int32 or data.__class__ is dbus.UInt32:
ret = int(data)
elif data.__class__ is dbus.Byte:
ret = byte(data)
ret = int(data)
return ret

2
pyweb/mumble/admin.py

@ -18,7 +18,7 @@ from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from forms import MumbleAdminForm
from models import *
from models import Mumble, MumbleUser
class MumbleAdmin(admin.ModelAdmin):
list_display = [ 'name', 'addr', 'port', 'booted', 'getIsPublic', 'getUsersRegged', 'getUsersOnline', 'getChannelCnt' ];

3
pyweb/mumble/forms.py

@ -18,10 +18,11 @@ import socket
import re
from django import forms
from django.conf import settings
from django.forms import Form, ModelForm
from django.utils.translation import ugettext_lazy as _
from models import *
from models import Mumble, MumbleUser
class MumbleAdminForm( ModelForm ):

2
pyweb/mumble/management/commands/checkenv.py

@ -118,7 +118,7 @@ class Command( BaseCommand ):
else:
for mumble in mm:
try:
ctl = mumble.ctl;
mumble.getCtl();
except Exception, err:
raise TestFailed(
"Connecting to Murmur `%s` (%s) failed: %s" % ( mumble.name, mumble.dbus, err )

2
pyweb/mumble/management/server_detect.py

@ -17,7 +17,7 @@
import os
from mumble import models
from mumble.mctl import *
from mumble.mctl import MumbleCtlBase
def find_in_dicts( keys, conf, default, valueIfNotFound=None ):
if not isinstance( keys, tuple ):

4
pyweb/mumble/mmobjects.py

@ -14,8 +14,6 @@
* GNU General Public License for more details.
"""
import mctl
import datetime
from time import time
from os.path import join
@ -167,7 +165,7 @@ class mmPlayer( object ):
self.channel.players.append( self );
if self.isAuthed:
from models import Mumble, MumbleUser
from models import MumbleUser
try:
self.mumbleuser = MumbleUser.objects.get( mumbleid=self.userid, server=srvInstance );
except MumbleUser.DoesNotExist:

37
pyweb/mumble/models.py

@ -22,8 +22,8 @@ from django.db import models
from django.db.models import signals
from django.conf import settings
from mmobjects import *
from mctl import *
from mumble.mmobjects import mmChannel, mmPlayer
from mumble.mctl import MumbleCtlBase
@ -43,22 +43,30 @@ class Mumble( models.Model ):
"""
name = models.CharField( _('Server Name'), max_length = 200 );
dbus = models.CharField( _('DBus or ICE base'), max_length = 200, default = settings.DEFAULT_CONN, help_text=_("Examples: 'net.sourceforge.mumble.murmur' for DBus or 'Meta:tcp -h 127.0.0.1 -p 6502' for Ice.") );
dbus = models.CharField( _('DBus or ICE base'), max_length = 200, default = settings.DEFAULT_CONN, help_text=_(
"Examples: 'net.sourceforge.mumble.murmur' for DBus or 'Meta:tcp -h 127.0.0.1 -p 6502' for Ice.") );
srvid = models.IntegerField( _('Server ID'), editable = False );
addr = models.CharField( _('Server Address'), max_length = 200, help_text=_("Hostname or IP address to bind to. You should use a hostname here, because it will appear on the global server list.") );
port = models.IntegerField( _('Server Port'), help_text=_("Port number to bind to. Use -1 to auto assign one."), default=settings.MUMBLE_DEFAULT_PORT );
addr = models.CharField( _('Server Address'), max_length = 200, help_text=_(
"Hostname or IP address to bind to. You should use a hostname here, because it will appear on the "
"global server list.") );
port = models.IntegerField( _('Server Port'), default=settings.MUMBLE_DEFAULT_PORT, help_text=_(
"Port number to bind to. Use -1 to auto assign one.") );
url = models.CharField( _('Website URL'), max_length = 200, blank = True );
motd = models.TextField( _('Welcome Message'), blank = True );
passwd = models.CharField( _('Server Password'), max_length = 200, blank = True, help_text=_("Password required to join. Leave empty for public servers.") );
passwd = models.CharField( _('Server Password'), max_length = 200, blank = True, help_text=_(
"Password required to join. Leave empty for public servers.") );
supw = models.CharField( _('Superuser Password'), max_length = 200, blank = True );
users = models.IntegerField( _('Max. Users'), blank = True, null = True );
bwidth = models.IntegerField( _('Bandwidth [Bps]'), blank = True, null = True );
sslcrt = models.TextField( _('SSL Certificate'), blank = True );
sslkey = models.TextField( _('SSL Key'), blank = True );
obfsc = models.BooleanField( _('IP Obfuscation'), default = False, help_text=_("If on, IP adresses of the clients are not logged.") );
obfsc = models.BooleanField( _('IP Obfuscation'), default = False, help_text=_(
"If on, IP adresses of the clients are not logged.") );
player = models.CharField( _('Player name regex'), max_length=200, default=r'[-=\w\[\]\{\}\(\)\@\|\.]+' );
channel = models.CharField( _('Channel name regex'), max_length=200, default=r'[ \-=\w\#\[\]\{\}\(\)\@\|]+' );
defchan = models.IntegerField( _('Default channel'), default=0, help_text=_("Enter the ID of the default channel here. The Channel viewer displays the ID to server admins on the channel detail page."));
defchan = models.IntegerField( _('Default channel'), default=0, help_text=_(
"Enter the ID of the default channel here. The Channel viewer displays the ID to "
"server admins on the channel detail page."));
booted = models.BooleanField( _('Boot Server'), default = True );
class Meta:
@ -81,7 +89,8 @@ class Mumble( models.Model ):
users_regged = property( lambda self: self.mumbleuser_set.count(), doc="Number of registered users." );
users_online = property( lambda self: len(self.ctl.getPlayers(self.srvid)), doc="Number of online users." );
channel_cnt = property( lambda self: len(self.ctl.getChannels(self.srvid)), doc="Number of channels." );
is_public = property( lambda self: self.passwd == '', doc="False if a password is needed to join this server." );
is_public = property( lambda self: self.passwd == '',
doc="False if a password is needed to join this server." );
is_server = True;
is_channel = False;
@ -402,7 +411,11 @@ class MumbleUser( models.Model ):
self._registration = None;
def __unicode__( self ):
return _("Mumble user %(mu)s on %(srv)s owned by Django user %(du)s") % { 'mu': self.name, 'srv': self.server, 'du': self.owner };
return _("Mumble user %(mu)s on %(srv)s owned by Django user %(du)s") % {
'mu': self.name,
'srv': self.server,
'du': self.owner
};
def save( self, dontConfigureMurmur=False ):
"""Save the settings in this model to Murmur."""
@ -498,7 +511,9 @@ class MumbleUser( models.Model ):
"""Read an image from the infile and install it as the user's texture."""
self.server.ctl.setTexture(self.server.srvid, self.mumbleid, infile)
texture = property( getTexture, setTexture, doc="Get the texture as a PIL Image or read from a file (pass the path)." );
texture = property( getTexture, setTexture,
doc="Get the texture as a PIL Image or read from a file (pass the path)."
);
def hasTexture( self ):
""" Check if this user has a texture set. """

4
pyweb/mumble/murmurenvutils.py

@ -91,7 +91,7 @@ def update_dbase( version ):
if not exists( murmurfile ):
raise EnvironmentError( "Murmur's database could not be found: '%s' does not exist!" % murmurfile );
dbasefile = join( settings.TEST_MURMUR_FILES_DIR, "murmur-%s.db3" % version );
copyfile( dbasefile, target );
copyfile( murmurfile, dbasefile );
def run_murmur( version ):
@ -106,8 +106,6 @@ def run_murmur( version ):
binary_candidates = ( 'murmur.64', 'murmur.x86', 'murmurd' );
files = os.listdir( murmur_root );
for binname in binary_candidates:
if exists( join( murmur_root, binname ) ):
process = subprocess.Popen(

5
pyweb/mumble/tests.py

@ -14,11 +14,10 @@
* GNU General Public License for more details.
"""
import os
from django.conf import settings
from django.test import TestCase
from models import *
from models import Mumble
from utils import ObjectInfo

2
pyweb/mumble/urls.py

@ -14,7 +14,7 @@
* GNU General Public License for more details.
"""
from django.conf.urls.defaults import *
from django.conf.urls.defaults import patterns
urlpatterns = patterns(
'mumble.views',

21
pyweb/mumble/views.py

@ -16,7 +16,6 @@
import simplejson
from StringIO import StringIO
from os.path import join
from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404
from django.template import RequestContext
@ -29,8 +28,8 @@ from django.core.urlresolvers import reverse
from django.contrib.auth import views as auth_views
from models import Mumble, MumbleUser
from forms import *
from mmobjects import *
from forms import MumbleForm, MumbleUserForm, MumbleUserPasswordForm
from forms import MumbleUserLinkForm, MumbleTextureForm
def redir( request ):
@ -177,11 +176,11 @@ def show( request, server ):
# ChannelTable is a somewhat misleading name, as it actually contains channels and players.
channelTable = [];
for id in srv.channels:
if id != 0 and srv.channels[id].show:
channelTable.append( srv.channels[id] );
for id in srv.players:
channelTable.append( srv.players[id] );
for cid in srv.channels:
if cid != 0 and srv.channels[cid].show:
channelTable.append( srv.channels[cid] );
for pid in srv.players:
channelTable.append( srv.players[pid] );
show_url = reverse( show, kwargs={ 'server': srv.id } );
login_url = reverse( auth_views.login );
@ -250,9 +249,9 @@ def showTexture( request, server, userid = None ):
except ValueError:
raise Http404();
else:
buffer = StringIO();
img.save( buffer, "PNG" );
return HttpResponse( buffer.getvalue(), "image/png" );
buf = StringIO();
img.save( buf, "PNG" );
return HttpResponse( buf.getvalue(), "image/png" );
@login_required

2
pyweb/urls.py

@ -14,7 +14,7 @@
* GNU General Public License for more details.
"""
from django.conf.urls.defaults import *
from django.conf.urls.defaults import patterns, include
# Uncomment the next two lines to enable the admin:
from django.contrib import admin

13
pyweb/views.py

@ -14,26 +14,17 @@
* GNU General Public License for more details.
"""
from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.conf import settings
from mumble.models import Mumble, MumbleUser
#from guestbook.models import Entry, Comment
#from forum.models import Post
from mumble.models import MumbleUser
@login_required
def profile( request ):
userdata = {
"ProfileActive": True,
"mumbleaccs": MumbleUser.objects.filter( owner = request.user ),
# "gbposts": Entry.objects.filter( author = request.user ).count(),
# "gbcomments": Comment.objects.filter( author = request.user ).count(),
# "forumposts": Post.objects.filter( author = request.user ).count(),
};
return render_to_response(

Loading…
Cancel
Save