+def translate_action(*command):
+ """Convert a Telnet command sequence into text suitable for logging."""
+ try:
+ command_name = command_names[command[0]]
+ except KeyError:
+ # This should never happen since we filter unknown commands from
+ # the input queue, but added here for completeness since logging
+ # should never crash the process
+ command_name = str(command[0])
+ try:
+ option_name = option_names[command[1]]
+ except KeyError:
+ # This can happen for any of the myriad of Telnet options missing
+ # from the option_names dict
+ option_name = str(command[1])
+ return "%s %s" % (command_name, option_name)
+
+