From b779ab9cb84d7b41fe6d5de088f05035ccd7d1e8 Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Tue, 23 Feb 2010 19:35:31 +0100 Subject: [PATCH] when detecting a new instance fails due to a duplicate entry, print both. --- pyweb/mumble/management/server_detect.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/pyweb/mumble/management/server_detect.py b/pyweb/mumble/management/server_detect.py index 5ffb748..87a8de3 100644 --- a/pyweb/mumble/management/server_detect.py +++ b/pyweb/mumble/management/server_detect.py @@ -16,6 +16,7 @@ import os, getpass +from django.db import DatabaseError from django.conf import settings from mumble import models @@ -123,12 +124,31 @@ def find_existing_instances( **kwargs ): if v > 1: print "Syncing Murmur instance... ", - instance.configureFromMurmur(); if v > 1: print instance.name; - instance.save( dontConfigureMurmur=True ); + try: + instance.configureFromMurmur(); + except DatabaseError, err: + try: + # Find instances with the same address/port + dup = models.Mumble.objects.get( addr=instance.addr, port=instance.port ) + except Mumble.DoesNotExist: + # None exist - this must've been something else. + raise err + else: + print "ERROR: There is already another server instance registered" + print " on the same address and port." + print " New Server Name:", instance.name + print " Address:", instance.addr + print " Port:", instance.port + print " Connection string:", instance.server.dbus + print "Duplicate Server Name:", dup.name + print " Address:", dup.addr + print " Port:", dup.port + print " Connection string:", dup.server.dbus + return False # Now search for players on this server that have not yet been registered if instance.booted: