From 0e7397194ba9fad3e199efa3ba39365f5403892f Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Fri, 12 Jun 2009 14:38:45 +0200 Subject: [PATCH] prevent infinite loop + minor improvements --- pyweb/mumble/management.py | 4 ++-- pyweb/mumble/mmobjects.py | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pyweb/mumble/management.py b/pyweb/mumble/management.py index 1c2d698..7405b5e 100755 --- a/pyweb/mumble/management.py +++ b/pyweb/mumble/management.py @@ -58,7 +58,7 @@ def find_existing_instances( **kwargs ): print "string's format." print - dbusName = raw_input( "Service string: " ); + dbusName = raw_input( "Service string: " ).strip(); if not dbusName: if v: @@ -141,7 +141,7 @@ def find_existing_instances( **kwargs ): if playerdata[0] == 0: continue; if v > 1: - print "Checking Player with id %d and name '%s'." % playerdata[:2]; + print "Checking Player with id %d and name '%s'." % ( int(playerdata[0]), playerdata[1] ); try: models.MumbleUser.objects.get( server=instance, mumbleid=playerdata[0] ); except models.MumbleUser.DoesNotExist: diff --git a/pyweb/mumble/mmobjects.py b/pyweb/mumble/mmobjects.py index a7c5813..e73076a 100755 --- a/pyweb/mumble/mmobjects.py +++ b/pyweb/mumble/mmobjects.py @@ -42,7 +42,11 @@ class mmServer( object ): chanlist = ctl.getChannels(model.srvid); # sometimes, ICE seems to return the Channel list in a weird order. - while len(chanlist): + # itercount prevents infinite loops. + itercount = 0; + maxiter = len(chanlist) * 3; + while len(chanlist) and itercount < maxiter: + itercount += 1; #print len(chanlist) for theChan in chanlist: # Channels - Fields: 0 = ID, 1 = Name, 2 = Parent-ID, 3 = Links