Remove features override

This commit is contained in:
Andrew Kay 2023-01-03 21:52:58 -06:00
parent 5fc896be2e
commit c93b14ed1c
2 changed files with 3 additions and 40 deletions

View File

@ -3,12 +3,11 @@ oec.device
~~~~~~~~~~
"""
import os
import time
import logging
from more_itertools import chunked
from coax import read_feature_ids, parse_features, ReadTerminalId, ReadExtendedId, \
Feature, ProtocolError
ProtocolError
from coax.multiplexer import PORT_MAP_3299
logger = logging.getLogger(__name__)
@ -103,37 +102,9 @@ def get_ids(interface, device_address, extended_id_retry_attempts=3):
def get_features(interface, device_address):
commands = read_feature_ids()
ids = interface.execute([address_commands(device_address, command) for command in commands])
ids = interface.execute(address_commands(device_address, commands))
features = parse_features(ids, commands)
# Add override features - for example, this can be used to add an unreported
# EAB feature to a IBM 3179 terminal.
if 'COAX_FEATURES' in os.environ:
for override in os.environ['COAX_FEATURES'].split(','):
if '@' not in override:
logger.warning(f'Invalid feature override: {override}')
continue
(name, address) = override.split('@')
try:
feature = Feature[name]
except KeyError:
logger.warning(f'Invalid feature override: {override}')
continue
try:
address = int(address)
except ValueError:
logger.warning(f'Invalid feature override: {override}')
continue
logger.info(f'Adding override feature {feature} @ {address}')
features[feature] = address
return features
return parse_features(ids, commands)
def _jumbo_write_split_data(data, max_length, first_chunk_max_length_adjustment=-1):
if max_length is None:

View File

@ -146,14 +146,6 @@ class GetFeaturesTestCase(unittest.TestCase):
# Assert
self.assertEqual(features, { Feature.EAB: 7 })
def test_override(self):
# Act
with patch.dict('oec.device.os.environ', { 'COAX_FEATURES': 'EAB@7' }):
features = get_features(InterfaceWrapper(self.interface), None)
# Assert
self.assertEqual(features, { Feature.EAB: 7 })
class JumboWriteSplitDataTestCase(unittest.TestCase):
def test_no_split_strategy(self):
for data in [bytes(range(0, 64)), (bytes.fromhex('00'), 64)]: