mirror of
https://github.com/lowobservable/oec.git
synced 2026-05-02 06:16:16 +00:00
Improve TN3270E support
This commit is contained in:
@@ -4,8 +4,8 @@ oec.tn3270
|
||||
"""
|
||||
|
||||
import logging
|
||||
from tn3270 import Telnet, Emulator, AttributeCell, CharacterCell, AID, Color, Highlight, \
|
||||
OperatorError, ProtectedCellOperatorError, FieldOverflowOperatorError
|
||||
from tn3270 import Telnet, TN3270EFunction, Emulator, AttributeCell, CharacterCell, AID, Color, \
|
||||
Highlight, OperatorError, ProtectedCellOperatorError, FieldOverflowOperatorError
|
||||
from tn3270.ebcdic import DUP, FM
|
||||
|
||||
from .session import Session, SessionDisconnectedError
|
||||
@@ -47,7 +47,7 @@ AID_KEY_MAP = {
|
||||
class TN3270Session(Session):
|
||||
"""TN3270 session."""
|
||||
|
||||
def __init__(self, terminal, host, port, device_names, character_encoding):
|
||||
def __init__(self, terminal, host, port, device_names, character_encoding, tn3270e_profile):
|
||||
super().__init__(terminal)
|
||||
|
||||
self.logger = logging.getLogger(__name__)
|
||||
@@ -56,6 +56,7 @@ class TN3270Session(Session):
|
||||
self.port = port
|
||||
self.device_names = device_names
|
||||
self.character_encoding = character_encoding
|
||||
self.tn3270e_profile = tn3270e_profile
|
||||
|
||||
self.telnet = None
|
||||
self.emulator = None
|
||||
@@ -191,12 +192,14 @@ class TN3270Session(Session):
|
||||
|
||||
self.logger.info(f'Terminal Type = {terminal_type}')
|
||||
|
||||
self.telnet = Telnet(terminal_type)
|
||||
tn3270e_args = _get_tn3270e_args(self.tn3270e_profile)
|
||||
|
||||
self.telnet = Telnet(terminal_type, **tn3270e_args)
|
||||
|
||||
self.telnet.open(self.host, self.port, self.device_names)
|
||||
|
||||
if self.telnet.is_tn3270e_negotiated:
|
||||
self.logger.info(f'TN3270E mode negotiated: Device Type = {self.telnet.device_type}, Device Name = {self.telnet.device_name}')
|
||||
self.logger.info(f'TN3270E mode negotiated: Device Type = {self.telnet.device_type}, Device Name = {self.telnet.device_name}, Functions = {self.telnet.tn3270e_functions}')
|
||||
else:
|
||||
self.logger.debug('Unable to negotiate TN3270E mode')
|
||||
|
||||
@@ -311,3 +314,18 @@ def _map_formatting(formatting):
|
||||
byte |= 0xc0
|
||||
|
||||
return byte
|
||||
|
||||
def _get_tn3270e_args(profile):
|
||||
is_tn3270e_enabled = True
|
||||
tn3270e_functions = [TN3270EFunction.RESPONSES]
|
||||
|
||||
if profile == 'off':
|
||||
is_tn3270e_enabled = False
|
||||
tn3270e_functions = None
|
||||
elif profile == 'basic':
|
||||
tn3270e_functions = []
|
||||
|
||||
return {
|
||||
'is_tn3270e_enabled': is_tn3270e_enabled,
|
||||
'tn3270e_functions': tn3270e_functions
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user