Updates to import statements:

- Import importlib, os, and sys to each python script.
 - Append "lanforge-scripts" root directory to the system path, allowing each script to be called from an antecedent directory. e.g.
if 'lanforge-scripts' not in sys.path:
    sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../../")))
 - All statements of the form 'from <module> import <class>' replace with:
<module> = importlib.import_module("lanforge-scripts.<directory>.<module>")
<class> = <module>.<class>
This commit is contained in:
erinnerim
2021-09-15 16:17:16 -07:00
parent 5404d9068b
commit 1d7578251c
128 changed files with 1639 additions and 1388 deletions

View File

@@ -1,21 +1,24 @@
#!/usr/bin/env python3
# Example of how to instantiate StaConnect and run the test
import sys
import os
import importlib
import time
import argparse
if sys.version_info[0] != 3:
print("This script requires Python 3")
exit(1)
if 'py-json' not in sys.path:
sys.path.append('../py-json')
if 'lanforge-scripts' not in sys.path:
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../")))
# if you lack __init__.py in this directory you will not find sta_connect module
import sta_connect
from sta_connect import StaConnect
import time
import argparse
from LANforge.lfcli_base import LFCliBase
lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base")
LFCliBase = lfcli_base.LFCliBase
sta_connect = importlib.import_module("lanforge-scripts.py-scripts.sta_connect")
StaConnect = sta_connect.StaConnect
def main():
parser = LFCliBase.create_basic_argparse(