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.
|
return a CommandCandidates object.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from src.utils.logger import log_trace
|
||||||
|
|
||||||
def cmdparser(raw_string, cmdset, caller, match_index=None):
|
def cmdparser(raw_string, cmdset, caller, match_index=None):
|
||||||
"""
|
"""
|
||||||
This function is called by the cmdhandler once it has
|
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.
|
# match everything that begins with a matching cmdname.
|
||||||
l_raw_string = raw_string.lower()
|
l_raw_string = raw_string.lower()
|
||||||
for cmd in cmdset:
|
for cmd in cmdset:
|
||||||
matches.extend([create_match(cmdname, raw_string, cmd)
|
try:
|
||||||
for cmdname in [cmd.key] + cmd.aliases
|
matches.extend([create_match(cmdname, raw_string, cmd)
|
||||||
if cmdname and l_raw_string.startswith(cmdname.lower())
|
for cmdname in [cmd.key] + cmd.aliases
|
||||||
and (not cmd.arg_regex or
|
if cmdname and l_raw_string.startswith(cmdname.lower())
|
||||||
cmd.arg_regex.match(l_raw_string[len(cmdname):]))])
|
and (not cmd.arg_regex or
|
||||||
|
cmd.arg_regex.match(l_raw_string[len(cmdname):]))])
|
||||||
|
except Exception:
|
||||||
|
log_trace()
|
||||||
|
|
||||||
if not matches:
|
if not matches:
|
||||||
# no matches found.
|
# no matches found.
|
||||||
if '-' in raw_string:
|
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
|
generic hook method for engine to call in order to send data
|
||||||
through the telnet connection.
|
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:
|
try:
|
||||||
string = utils.to_str(string, encoding=self.encoding)
|
string = utils.to_str(string, encoding=self.encoding)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
self.sendLine(str(e))
|
self.sendLine(str(e))
|
||||||
return
|
return
|
||||||
xterm256 = self.protocol_flags.get('TTYPE', {}).get('256 COLORS')
|
ttype = self.protocol_flags.get('TTYPE', {})
|
||||||
nomarkup = not (xterm256 or not self.protocol_flags.get('TTYPE')
|
nomarkup = not (ttype.get('256 COLORS') or ttype.get('ANSI') or not ttype.get("init_done"))
|
||||||
or self.protocol_flags.get('TTYPE', {}).get('ANSI'))
|
raw = False
|
||||||
raw = False
|
|
||||||
if type(data) == dict:
|
if type(data) == dict:
|
||||||
# check if we want escape codes to go through unparsed.
|
# check if we want escape codes to go through unparsed.
|
||||||
raw = data.get("raw", False)
|
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)
|
nomarkup = data.get("nomarkup", False)
|
||||||
if raw:
|
if raw:
|
||||||
self.sendLine(string)
|
self.sendLine(string)
|
||||||
else:
|
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.ttype_step = 0
|
||||||
self.protocol = protocol
|
self.protocol = protocol
|
||||||
self.protocol.protocol_flags['TTYPE'] = {}
|
self.protocol.protocol_flags['TTYPE'] = {"init_done":False}
|
||||||
|
|
||||||
# setup protocol to handle ttype initialization and negotiation
|
# setup protocol to handle ttype initialization and negotiation
|
||||||
self.protocol.negotiationMap[TTYPE] = self.do_ttype
|
self.protocol.negotiationMap[TTYPE] = self.do_ttype
|
||||||
|
|
@ -52,7 +52,7 @@ class Ttype(object):
|
||||||
"""
|
"""
|
||||||
Callback if ttype is not supported by client.
|
Callback if ttype is not supported by client.
|
||||||
"""
|
"""
|
||||||
pass
|
self.protocol.protocol_flags['TTYPE'] = False
|
||||||
|
|
||||||
def do_ttype(self, option):
|
def do_ttype(self, option):
|
||||||
"""
|
"""
|
||||||
|
|
@ -65,6 +65,9 @@ class Ttype(object):
|
||||||
stored on protocol.protocol_flags under the TTYPE key.
|
stored on protocol.protocol_flags under the TTYPE key.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if self.protocol.protocol_flags['TTYPE']['init_done']:
|
||||||
|
return
|
||||||
|
|
||||||
self.ttype_step += 1
|
self.ttype_step += 1
|
||||||
|
|
||||||
if self.ttype_step == 1:
|
if self.ttype_step == 1:
|
||||||
|
|
@ -89,5 +92,7 @@ class Ttype(object):
|
||||||
self.protocol.protocol_flags['TTYPE'][standard] = status
|
self.protocol.protocol_flags['TTYPE'][standard] = status
|
||||||
if status:
|
if status:
|
||||||
option = option % codenum
|
option = option % codenum
|
||||||
|
self.protocol.protocol_flags['TTYPE']['init_done'] = True
|
||||||
|
|
||||||
#print "ttype results:", self.protocol.protocol_flags['TTYPE']
|
#print "ttype results:", self.protocol.protocol_flags['TTYPE']
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue