mirror of
https://github.com/evennia/evennia.git
synced 2026-04-01 13:37:17 +02:00
Adding more lenient checks of TTYPE to avoid a visible traceback. The error with TTYPE utf-8 tracebacks seems to be in an older version of tintin++, newer versions don't show this behaviour. Older versions of tintin++ will display one Huh? (with logged traceback) after which everything will work. This is reported in issue 219.
This commit is contained in:
parent
6aac9e6c2b
commit
8ada50fcb7
3 changed files with 25 additions and 14 deletions
|
|
@ -5,6 +5,8 @@ replacing cmdparser function. The replacement parser must
|
|||
return a CommandCandidates object.
|
||||
"""
|
||||
|
||||
from src.utils.logger import log_trace
|
||||
|
||||
def cmdparser(raw_string, cmdset, caller, match_index=None):
|
||||
"""
|
||||
This function is called by the cmdhandler once it has
|
||||
|
|
@ -46,11 +48,15 @@ def cmdparser(raw_string, cmdset, caller, match_index=None):
|
|||
# match everything that begins with a matching cmdname.
|
||||
l_raw_string = raw_string.lower()
|
||||
for cmd in cmdset:
|
||||
matches.extend([create_match(cmdname, raw_string, cmd)
|
||||
for cmdname in [cmd.key] + cmd.aliases
|
||||
if cmdname and l_raw_string.startswith(cmdname.lower())
|
||||
and (not cmd.arg_regex or
|
||||
cmd.arg_regex.match(l_raw_string[len(cmdname):]))])
|
||||
try:
|
||||
matches.extend([create_match(cmdname, raw_string, cmd)
|
||||
for cmdname in [cmd.key] + cmd.aliases
|
||||
if cmdname and l_raw_string.startswith(cmdname.lower())
|
||||
and (not cmd.arg_regex or
|
||||
cmd.arg_regex.match(l_raw_string[len(cmdname):]))])
|
||||
except Exception:
|
||||
log_trace()
|
||||
|
||||
if not matches:
|
||||
# no matches found.
|
||||
if '-' in raw_string:
|
||||
|
|
|
|||
|
|
@ -133,23 +133,23 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
|||
"""
|
||||
generic hook method for engine to call in order to send data
|
||||
through the telnet connection.
|
||||
Data Evennia -> Player. 'data' argument is not used
|
||||
Data Evennia -> Player.
|
||||
data argument may contain a dict with output flags.
|
||||
"""
|
||||
try:
|
||||
string = utils.to_str(string, encoding=self.encoding)
|
||||
except Exception, e:
|
||||
self.sendLine(str(e))
|
||||
return
|
||||
xterm256 = self.protocol_flags.get('TTYPE', {}).get('256 COLORS')
|
||||
nomarkup = not (xterm256 or not self.protocol_flags.get('TTYPE')
|
||||
or self.protocol_flags.get('TTYPE', {}).get('ANSI'))
|
||||
raw = False
|
||||
ttype = self.protocol_flags.get('TTYPE', {})
|
||||
nomarkup = not (ttype.get('256 COLORS') or ttype.get('ANSI') or not ttype.get("init_done"))
|
||||
raw = False
|
||||
if type(data) == dict:
|
||||
# check if we want escape codes to go through unparsed.
|
||||
raw = data.get("raw", False)
|
||||
# check if we want to remove all markup
|
||||
# check if we want to remove all markup (TTYPE override)
|
||||
nomarkup = data.get("nomarkup", False)
|
||||
if raw:
|
||||
self.sendLine(string)
|
||||
else:
|
||||
self.sendLine(ansi.parse_ansi(string, strip_ansi=nomarkup, xterm256=xterm256))
|
||||
self.sendLine(ansi.parse_ansi(string, strip_ansi=nomarkup, xterm256=ttype.get('256 COLORS')))
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class Ttype(object):
|
|||
"""
|
||||
self.ttype_step = 0
|
||||
self.protocol = protocol
|
||||
self.protocol.protocol_flags['TTYPE'] = {}
|
||||
self.protocol.protocol_flags['TTYPE'] = {"init_done":False}
|
||||
|
||||
# setup protocol to handle ttype initialization and negotiation
|
||||
self.protocol.negotiationMap[TTYPE] = self.do_ttype
|
||||
|
|
@ -52,7 +52,7 @@ class Ttype(object):
|
|||
"""
|
||||
Callback if ttype is not supported by client.
|
||||
"""
|
||||
pass
|
||||
self.protocol.protocol_flags['TTYPE'] = False
|
||||
|
||||
def do_ttype(self, option):
|
||||
"""
|
||||
|
|
@ -65,6 +65,9 @@ class Ttype(object):
|
|||
stored on protocol.protocol_flags under the TTYPE key.
|
||||
"""
|
||||
|
||||
if self.protocol.protocol_flags['TTYPE']['init_done']:
|
||||
return
|
||||
|
||||
self.ttype_step += 1
|
||||
|
||||
if self.ttype_step == 1:
|
||||
|
|
@ -89,5 +92,7 @@ class Ttype(object):
|
|||
self.protocol.protocol_flags['TTYPE'][standard] = status
|
||||
if status:
|
||||
option = option % codenum
|
||||
self.protocol.protocol_flags['TTYPE']['init_done'] = True
|
||||
|
||||
#print "ttype results:", self.protocol.protocol_flags['TTYPE']
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue