mirror of
https://github.com/lowobservable/oec.git
synced 2026-01-11 23:53:04 +00:00
Remove features override
This commit is contained in:
parent
5fc896be2e
commit
c93b14ed1c
@ -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:
|
||||
|
||||
@ -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)]:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user