Refactor code for readability and compatibility.
This commit is contained in:
parent
a09835049b
commit
c6d9c0619e
43 changed files with 129 additions and 112 deletions
|
|
@ -405,6 +405,7 @@ def evennia_version():
|
|||
import evennia
|
||||
version = evennia.__version__
|
||||
except ImportError:
|
||||
# even if evennia is not found, we should not crash here.
|
||||
pass
|
||||
try:
|
||||
rev = check_output(
|
||||
|
|
@ -412,6 +413,7 @@ def evennia_version():
|
|||
shell=True, cwd=EVENNIA_ROOT, stderr=STDOUT).strip()
|
||||
version = "%s (rev %s)" % (version, rev)
|
||||
except (IOError, CalledProcessError):
|
||||
# move on if git is not answering
|
||||
pass
|
||||
return version
|
||||
|
||||
|
|
@ -520,7 +522,7 @@ def create_settings_file(init=True):
|
|||
if not init:
|
||||
# if not --init mode, settings file may already exist from before
|
||||
if os.path.exists(settings_path):
|
||||
inp = raw_input("server/conf/settings.py already exists. "
|
||||
inp = input("server/conf/settings.py already exists. "
|
||||
"Do you want to reset it? y/[N]> ")
|
||||
if not inp.lower() == 'y':
|
||||
print ("Aborted.")
|
||||
|
|
@ -659,14 +661,13 @@ def get_pid(pidfile):
|
|||
pidfile (str): The path of the pid file.
|
||||
|
||||
Returns:
|
||||
pid (str): The process id.
|
||||
pid (str or None): The process id.
|
||||
|
||||
"""
|
||||
pid = None
|
||||
if os.path.exists(pidfile):
|
||||
f = open(pidfile, 'r')
|
||||
pid = f.read()
|
||||
return pid
|
||||
with open(pidfile, 'r') as f:
|
||||
pid = f.read()
|
||||
return pid
|
||||
|
||||
|
||||
def del_pid(pidfile):
|
||||
|
|
@ -722,6 +723,7 @@ def kill(pidfile, signal=SIG, succmsg="", errmsg="",
|
|||
SetConsoleCtrlHandler(None, True)
|
||||
GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0)
|
||||
except KeyboardInterrupt:
|
||||
# We must catch and ignore the interrupt sent.
|
||||
pass
|
||||
else:
|
||||
# Linux can send the SIGINT signal directly
|
||||
|
|
@ -986,6 +988,8 @@ def run_dummyrunner(number_of_dummies):
|
|||
try:
|
||||
call(cmdstr, env=getenv())
|
||||
except KeyboardInterrupt:
|
||||
# this signals the dummyrunner to stop cleanly and should
|
||||
# not lead to a traceback here.
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -133,13 +133,16 @@ class Mssp(object):
|
|||
|
||||
"ANSI": "1",
|
||||
"GMCP": "0",
|
||||
"ATCP": "0",
|
||||
"MCCP": "0",
|
||||
"MCP": "0",
|
||||
"MSDP": "0",
|
||||
"MSP": "0",
|
||||
"MXP": "0",
|
||||
"PUEBLO": "0",
|
||||
"SSL": "1",
|
||||
"UTF-8": "1",
|
||||
"ZMP": "0",
|
||||
"VT100": "0",
|
||||
"XTERM 256 COLORS": "0",
|
||||
|
||||
|
|
@ -180,16 +183,7 @@ class Mssp(object):
|
|||
"ROLEPLAYING": "None", # "None", "Accepted", "Encouraged", "Enforced"
|
||||
"TRAINING SYSTEM": "None", # "None", "Level", "Skill", "Both"
|
||||
"WORLD ORIGINALITY": "None", # "All Stock", "Mostly Stock", "Mostly Original", "All Original"
|
||||
|
||||
# Protocols (only change if you added/removed something manually)
|
||||
|
||||
"ATCP": "0",
|
||||
"MSDP": "0",
|
||||
"MCCP": "1",
|
||||
"SSL": "1",
|
||||
"UTF-8": "1",
|
||||
"ZMP": "0",
|
||||
"XTERM 256 COLORS": "0"}
|
||||
}
|
||||
|
||||
# update the static table with the custom one
|
||||
if MSSPTable_CUSTOM:
|
||||
|
|
|
|||
|
|
@ -364,6 +364,7 @@ class PortalSessionHandler(SessionHandler):
|
|||
self.data_out(session, text=[[_ERROR_MAX_CHAR], {}])
|
||||
return
|
||||
except Exception:
|
||||
# if there is a problem to send, we continue
|
||||
pass
|
||||
if session:
|
||||
now = time()
|
||||
|
|
|
|||
|
|
@ -364,6 +364,7 @@ class TelnetOOB(object):
|
|||
try:
|
||||
structure = json.loads(structure)
|
||||
except ValueError:
|
||||
# maybe the structure is not json-serialized at all
|
||||
pass
|
||||
args, kwargs = [], {}
|
||||
if hasattr(structure, "__iter__"):
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ class Ttype(object):
|
|||
try:
|
||||
option = "".join(option).lstrip(IS)
|
||||
except TypeError:
|
||||
# option is not on a suitable form for joining
|
||||
pass
|
||||
|
||||
if self.ttype_step == 0:
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ class WebSocketClient(Protocol, Session):
|
|||
kwargs["options"].update({"send_prompt": True})
|
||||
self.send_text(*args, **kwargs)
|
||||
|
||||
def send_default(session, cmdname, *args, **kwargs):
|
||||
def send_default(self, cmdname, *args, **kwargs):
|
||||
"""
|
||||
Data Evennia -> User.
|
||||
|
||||
|
|
@ -219,4 +219,4 @@ class WebSocketClient(Protocol, Session):
|
|||
|
||||
"""
|
||||
if not cmdname == "options":
|
||||
session.sendLine(json.dumps([cmdname, args, kwargs]))
|
||||
self.sendLine(json.dumps([cmdname, args, kwargs]))
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ class WebClient(resource.Resource):
|
|||
try:
|
||||
del self.requests[csessid]
|
||||
except KeyError:
|
||||
# nothing left to delete
|
||||
pass
|
||||
|
||||
def _keepalive(self):
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ class ServerSession(Session):
|
|||
cchan = ChannelDB.objects.get_channel(cchan[0])
|
||||
cchan.msg("[%s]: %s" % (cchan.key, message))
|
||||
except Exception:
|
||||
pass
|
||||
logger.log_trace()
|
||||
logger.log_info(message)
|
||||
|
||||
def get_client_size(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue