From c44c6f908648230b5e743664ae8927eecb102bf3 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Wed, 1 Dec 2021 13:57:40 +0100 Subject: [PATCH] Conditional imports for serial-based interfaces --- RNS/Interfaces/AX25KISSInterface.py | 1 + RNS/Interfaces/KISSInterface.py | 1 + RNS/Interfaces/RNodeInterface.py | 1 + RNS/Interfaces/SerialInterface.py | 1 + 4 files changed, 4 insertions(+) diff --git a/RNS/Interfaces/AX25KISSInterface.py b/RNS/Interfaces/AX25KISSInterface.py index da7b218..ec9a24c 100644 --- a/RNS/Interfaces/AX25KISSInterface.py +++ b/RNS/Interfaces/AX25KISSInterface.py @@ -47,6 +47,7 @@ class AX25KISSInterface(Interface): serial = None def __init__(self, owner, name, callsign, ssid, port, speed, databits, parity, stopbits, preamble, txtail, persistence, slottime, flow_control): + import importlib if importlib.util.find_spec('serial') != None: import serial else: diff --git a/RNS/Interfaces/KISSInterface.py b/RNS/Interfaces/KISSInterface.py index 4c63f26..e2ccf2f 100644 --- a/RNS/Interfaces/KISSInterface.py +++ b/RNS/Interfaces/KISSInterface.py @@ -39,6 +39,7 @@ class KISSInterface(Interface): serial = None def __init__(self, owner, name, port, speed, databits, parity, stopbits, preamble, txtail, persistence, slottime, flow_control, beacon_interval, beacon_data): + import importlib if importlib.util.find_spec('serial') != None: import serial else: diff --git a/RNS/Interfaces/RNodeInterface.py b/RNS/Interfaces/RNodeInterface.py index eae0bcd..79e41ba 100644 --- a/RNS/Interfaces/RNodeInterface.py +++ b/RNS/Interfaces/RNodeInterface.py @@ -71,6 +71,7 @@ class RNodeInterface(Interface): CALLSIGN_MAX_LEN = 32 def __init__(self, owner, name, port, frequency = None, bandwidth = None, txpower = None, sf = None, cr = None, flow_control = False, id_interval = None, id_callsign = None): + import importlib if importlib.util.find_spec('serial') != None: import serial else: diff --git a/RNS/Interfaces/SerialInterface.py b/RNS/Interfaces/SerialInterface.py index 34e7a62..7fa699f 100755 --- a/RNS/Interfaces/SerialInterface.py +++ b/RNS/Interfaces/SerialInterface.py @@ -30,6 +30,7 @@ class SerialInterface(Interface): serial = None def __init__(self, owner, name, port, speed, databits, parity, stopbits): + import importlib if importlib.util.find_spec('serial') != None: import serial else: