From c49fbd7d99eda2d0b04c203d77fb65ff91eaccd9 Mon Sep 17 00:00:00 2001 From: Griatch Date: Fri, 4 May 2012 10:03:41 +0200 Subject: [PATCH] Removed 'with' statement; it's available in Python2.5, but one needs to use the future import to do that, so easiest to remove it. Resolves issue 230. --- game/evennia.py | 8 ++++---- game/manage.py | 5 +++-- src/server/amp.py | 7 +++++-- src/utils/utils.py | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/game/evennia.py b/game/evennia.py index 093dd16397..8c55bfc2bf 100755 --- a/game/evennia.py +++ b/game/evennia.py @@ -12,7 +12,7 @@ menu. Run the script with the -h flag to see usage information. import os import sys, signal from optparse import OptionParser -from subprocess import Popen, call +from subprocess import Popen # Set the Python path up so we can get to settings.py from here. sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) @@ -22,6 +22,7 @@ if not os.path.exists('settings.py'): # make sure we have a settings.py file. print " No settings.py file found. launching manage.py ..." + # this triggers the settings file creation. import game.manage print """ @@ -448,7 +449,6 @@ def main(): parser.add_option('-i', '--interactive', action='store_true', dest='interactive', default=False, help="Start given processes in interactive mode (log to stdout, don't start as a daemon).") options, args = parser.parse_args() - inter = options.interactive if not args: mode = "menu" @@ -460,10 +460,10 @@ def main(): service = args[1] if mode not in ['menu', 'start', 'reload', 'stop']: - print "mode should be none or one of 'menu', 'start', 'reload' or 'stop'." + print "mode should be none, 'menu', 'start', 'reload' or 'stop'." sys.exit() if service not in ['server', 'portal', 'all']: - print "service should be none or 'server', 'portal' or 'all'." + print "service should be none, 'server', 'portal' or 'all'." sys.exit() if mode == 'menu': diff --git a/game/manage.py b/game/manage.py index c388cfb85e..fc6c87a3cf 100755 --- a/game/manage.py +++ b/game/manage.py @@ -15,8 +15,9 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) # Get Evennia version #------------------------------------------------------------ try: - with open(os.pardir + os.sep + 'VERSION') as f: - VERSION = "%s-r%s" % (f.read().strip(), os.popen("hg id -i").read().strip()) + f = open(os.pardir + os.sep + 'VERSION', 'r''') + VERSION = "%s-r%s" % (f.read().strip(), os.popen("hg id -i").read().strip()) + f.close() except IOError: VERSION = "Unknown version" diff --git a/src/server/amp.py b/src/server/amp.py index 7809798c90..34b3261955 100644 --- a/src/server/amp.py +++ b/src/server/amp.py @@ -113,9 +113,12 @@ class AmpClientFactory(protocol.ReconnectingClientFactory): """ Called when the AMP connection to the MUD server is lost. """ - if not hasattr(self, "server_restart_mode"): + if hasattr(self, "server_restart_mode"): + self.maxDelay = 1 + else: # Don't translate this; avoiding loading django on portal side. - self.portal.sessions.announce_all(" Portal lost connection to Server.") + self.maxDelay = 10 + self.portal.sessions.announce_all(" ... Portal lost connection to Server.") protocol.ReconnectingClientFactory.clientConnectionLost(self, connector, reason) def clientConnectionFailed(self, connector, reason): diff --git a/src/utils/utils.py b/src/utils/utils.py index 0ec397cf76..d92ccafb2a 100644 --- a/src/utils/utils.py +++ b/src/utils/utils.py @@ -4,8 +4,8 @@ General helper functions that don't fit neatly under any given category. They provide some useful string and conversion methods that might be of use when designing your own game. - """ + from inspect import ismodule import os, sys, imp, types, math import textwrap