mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-10-31 10:48:02 +00:00 
			
		
		
		
	Finish pip package creation script
Signed-off-by: Matthew Stidham <stidmatt@gmail.com>
This commit is contained in:
		| @@ -69,37 +69,7 @@ class CreateL3(Realm): | |||||||
|         self._pass("PASS: Cross-connect build finished") |         self._pass("PASS: Cross-connect build finished") | ||||||
|  |  | ||||||
|  |  | ||||||
| def main(): | def main(args): | ||||||
|     parser = LFCliBase.create_basic_argparse( |  | ||||||
|         prog='create_l3.py', |  | ||||||
|         formatter_class=argparse.RawTextHelpFormatter, |  | ||||||
|         epilog='''\ |  | ||||||
|             Generate traffic between ports |  | ||||||
|             ''', |  | ||||||
|         description='''\ |  | ||||||
|         ''') |  | ||||||
|  |  | ||||||
|     required_args = None |  | ||||||
|     for group in parser._action_groups: |  | ||||||
|         if group.title == "required arguments": |  | ||||||
|             required_args = group |  | ||||||
|             break |  | ||||||
|     if required_args is not None: |  | ||||||
|         required_args.add_argument('--min_rate_a', help='--min_rate_a bps rate minimum for side_a', default=56000) |  | ||||||
|         required_args.add_argument('--min_rate_b', help='--min_rate_b bps rate minimum for side_b', default=56000) |  | ||||||
|         required_args.add_argument('--endp_a', help='--endp_a station list', default=["eth1"], action="append") |  | ||||||
|         required_args.add_argument('--endp_b', help='--upstream port', default="eth2") |  | ||||||
|  |  | ||||||
|     optional_args = None |  | ||||||
|     for group in parser._action_groups: |  | ||||||
|         if group.title == "optional arguments": |  | ||||||
|             optional_args = group |  | ||||||
|             break; |  | ||||||
|     if optional_args is not None: |  | ||||||
|         optional_args.add_argument('--mode', help='Used to force mode of stations', default=0) |  | ||||||
|         optional_args.add_argument('--ap', help='Used to force a connection to a particular AP') |  | ||||||
|         optional_args.add_argument('--number_template', help='Start the station numbering with a particular number. Default is 0000', default=0000) |  | ||||||
|     args = parser.parse_args() |  | ||||||
|  |  | ||||||
|     num_sta = 2 |     num_sta = 2 | ||||||
|     if (args.num_stations is not None) and (int(args.num_stations) > 0): |     if (args.num_stations is not None) and (int(args.num_stations) > 0): | ||||||
| @@ -126,4 +96,21 @@ def main(): | |||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||||
|     main() |     parser = LFCliBase.create_basic_argparse( | ||||||
|  |         prog='create_l3.py', | ||||||
|  |         formatter_class=argparse.RawTextHelpFormatter, | ||||||
|  |         epilog='''\ | ||||||
|  |             Generate traffic between ports | ||||||
|  |             ''', | ||||||
|  |         description='''\ | ||||||
|  |         ''') | ||||||
|  |     parser.add_argument('--min_rate_a', help='--min_rate_a bps rate minimum for side_a', default=56000) | ||||||
|  |     parser.add_argument('--min_rate_b', help='--min_rate_b bps rate minimum for side_b', default=56000) | ||||||
|  |     parser.add_argument('--endp_a', help='--endp_a station list', default=["eth1"], action="append", required=True) | ||||||
|  |     parser.add_argument('--endp_b', help='--upstream port', default="eth2", required=True) | ||||||
|  |     parser.add_argument('--mode', help='Used to force mode of stations', default=0) | ||||||
|  |     parser.add_argument('--ap', help='Used to force a connection to a particular AP') | ||||||
|  |     parser.add_argument('--number_template', help='Start the station numbering with a particular number. Default is 0000', default=0000) | ||||||
|  |     args = parser.parse_args() | ||||||
|  |  | ||||||
|  |     main(args) | ||||||
|   | |||||||
							
								
								
									
										6
									
								
								setup.cfg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								setup.cfg
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | |||||||
|  | [metadata] | ||||||
|  |  | ||||||
|  | license_files = license.txt | ||||||
|  |  | ||||||
|  | [options] | ||||||
|  | packages = find: | ||||||
							
								
								
									
										44
									
								
								setup.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										44
									
								
								setup.py
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,44 @@ | |||||||
|  | #!/usr/bin/env python3 | ||||||
|  |  | ||||||
|  | from setuptools import setup, find_packages | ||||||
|  |  | ||||||
|  | setup( | ||||||
|  |     name="lanforge_scripts", | ||||||
|  |     version="0.0.1", | ||||||
|  |     author="Candela Technologies", | ||||||
|  |     description="Automate LANforge devices", | ||||||
|  |     license='BSD 3-clause license', | ||||||
|  |     url='https://github.com/greearb/lanforge-scripts', | ||||||
|  |     long_description=open('README.md').read(), | ||||||
|  |     long_description_content_type="text/markdown", | ||||||
|  |     packages=find_packages(), | ||||||
|  |     install_requires=[ | ||||||
|  |         'pandas', | ||||||
|  |         'plotly', | ||||||
|  |         'numpy', | ||||||
|  |         'cryptography', | ||||||
|  |         'paramiko', | ||||||
|  |         'bokeh', | ||||||
|  |         'pyarrow', | ||||||
|  |         'websocket-client', | ||||||
|  |         'xlsxwriter', | ||||||
|  |         'pyshark', | ||||||
|  |         'influxdb', | ||||||
|  |         'influxdb-client', | ||||||
|  |         'matplotlib', | ||||||
|  |         'pdfkit', | ||||||
|  |         'pip-search', | ||||||
|  |         'pyserial', | ||||||
|  |         'pexpect-serial', | ||||||
|  |         'scp', | ||||||
|  |         'dash', | ||||||
|  |         'kaleido'], | ||||||
|  |     python_required='>=3.6, <4', | ||||||
|  |     classifiers=[ | ||||||
|  |         "Programming Language :: Python :: 3", | ||||||
|  |         "Operating System :: OS Independent", | ||||||
|  |     ], | ||||||
|  |     project_urls={ | ||||||
|  |         'Homepage': 'https://www.candelatech.com' | ||||||
|  |     } | ||||||
|  | ) | ||||||
							
								
								
									
										62
									
								
								to_pip.sh
									
									
									
									
									
								
							
							
						
						
									
										62
									
								
								to_pip.sh
									
									
									
									
									
								
							| @@ -1,7 +1,7 @@ | |||||||
| #! /bin/bash | #! /bin/bash | ||||||
| Help() | Help() | ||||||
| { | { | ||||||
|   echo "This script modifies lanforge scripts so that it can be imported into python as a library" |   echo "This script modifies lanforge scripts so that it can be imported into python as a library from the tar.gz file it creates" | ||||||
|   echo "store this repository in your python path, and then import lanforge_scripts from anywhere on your machine" |   echo "store this repository in your python path, and then import lanforge_scripts from anywhere on your machine" | ||||||
|   echo "An example of how to run this in python is like so:" |   echo "An example of how to run this in python is like so:" | ||||||
|   echo "import lanforge_scripts" |   echo "import lanforge_scripts" | ||||||
| @@ -12,6 +12,7 @@ Help() | |||||||
|   echo "EXPORT TO TAR FILE" |   echo "EXPORT TO TAR FILE" | ||||||
|   echo "./to_pip.sh -a -t TARGET_DIR" |   echo "./to_pip.sh -a -t TARGET_DIR" | ||||||
|   echo "The 't' flag tells to_pip where to store the tar file, -a tells it to make a tar file." |   echo "The 't' flag tells to_pip where to store the tar file, -a tells it to make a tar file." | ||||||
|  |   echo "When the archive is made, you can install it on any computer with `pip install lanforge_scripts.tar.gz`" | ||||||
| } | } | ||||||
|  |  | ||||||
| ARCHIVE=0 | ARCHIVE=0 | ||||||
| @@ -38,9 +39,9 @@ cd .. | |||||||
| mv lanforge-scripts lanforge_scripts | mv lanforge-scripts lanforge_scripts | ||||||
| cd lanforge_scripts | cd lanforge_scripts | ||||||
|  |  | ||||||
| ln -s py-scripts/ py_scripts | mv py-scripts/ py_scripts | ||||||
| ln -s py-json/ py_json | mv py-json/ py_json | ||||||
| ln -s py-dashboard/ py_dashboard | mv py-dashboard/ py_dashboard | ||||||
|  |  | ||||||
|  |  | ||||||
| echo "#Automate LANforge devices with lanforge-scripts | echo "#Automate LANforge devices with lanforge-scripts | ||||||
| @@ -206,7 +207,8 @@ sed -i -- 's/lf_cv_base = importlib.import_module("py-json.lf_cv_base")/from ..p | |||||||
| sed -i -- 's/base_profile = importlib.import_module("py-json.base_profile")/from ..py_json import base_profile/g' *.py | sed -i -- 's/base_profile = importlib.import_module("py-json.base_profile")/from ..py_json import base_profile/g' *.py | ||||||
| sed -i -- 's/add_file_endp = importlib.import_module("py-json.LANforge.add_file_endp")/from ..py_json.LANforge import add_file_endp/g' *.py | sed -i -- 's/add_file_endp = importlib.import_module("py-json.LANforge.add_file_endp")/from ..py_json.LANforge import add_file_endp/g' *.py | ||||||
| sed -i -- 's/lf_graph = importlib.import_module("py-scripts.lf_graph")/from ..py_scripts import lf_graph/g' *.py | sed -i -- 's/lf_graph = importlib.import_module("py-scripts.lf_graph")/from ..py_scripts import lf_graph/g' *.py | ||||||
| sed -i -- 's/GrafanaRequest = importlib.import_module("py-dashboard.GrafanaRequest")/from ..py_dashboard import GrafanaRequest/g' *.py | sed -i -- 's/GrafanaRequest = importlib.import_module("py-dashboard.GrafanaRequest")/from ..py_dashboard.GrafanaRequest import GrafanaRequest/g' *.py | ||||||
|  | sed -i -- 's/GrafanaRequest = GrafanaRequest.GrafanaRequest/ /g' *.py | ||||||
| sed -i -- 's/station_profile = importlib.import_module("py-json.station_profile")/from ..py_json import station_profile/g' *.py | sed -i -- 's/station_profile = importlib.import_module("py-json.station_profile")/from ..py_json import station_profile/g' *.py | ||||||
| sed -i -- 's/cv_test_manager = importlib.import_module("py-scripts.cv_test_manager")/from ..py_scripts import cv_test_manager/g' *.py | sed -i -- 's/cv_test_manager = importlib.import_module("py-scripts.cv_test_manager")/from ..py_scripts import cv_test_manager/g' *.py | ||||||
| sed -i -- 's/lf_report = importlib.import_module("py-scripts.lf_report")/from ..py_scripts import lf_report/g' *.py | sed -i -- 's/lf_report = importlib.import_module("py-scripts.lf_report")/from ..py_scripts import lf_report/g' *.py | ||||||
| @@ -316,6 +318,8 @@ sed -i -- 's/vap_profile = importlib.import_module("py-json.vap_profile")/from . | |||||||
| sed -i -- 's/station_profile = importlib.import_module("py-json.station_profile")/from ..py_json import station_profile/g' *.py | sed -i -- 's/station_profile = importlib.import_module("py-json.station_profile")/from ..py_json import station_profile/g' *.py | ||||||
| sed -i -- 's/PortUtils = port_utils.PortUtils/ /g' *.py | sed -i -- 's/PortUtils = port_utils.PortUtils/ /g' *.py | ||||||
| sed -i -- 's/LFCliBase = lfcli_base.LFCliBase/ /g' *.py | sed -i -- 's/LFCliBase = lfcli_base.LFCliBase/ /g' *.py | ||||||
|  | sed -i -- 's/pandas_extensions = importlib.import_module("py-json.LANforge.pandas_extensions")/from .LANforge.pandas_extensions import pandas_extensions/g' *.py | ||||||
|  | sed -i -- 's/pandas_extensions.pandas_extensions/pandas_extensions/g' *.py | ||||||
|  |  | ||||||
| # fix py_dashboard files | # fix py_dashboard files | ||||||
| sed -i -- 's/from GrafanaRequest/from ..py_dashboard.GrafanaRequest/g' *.py | sed -i -- 's/from GrafanaRequest/from ..py_dashboard.GrafanaRequest/g' *.py | ||||||
| @@ -383,6 +387,10 @@ sed -i -- 's/import LANforge.LFRequest/ /g' lfcli_base.py | |||||||
| sed -i -- 's/import .LFRequest/from . import LFRequest/g' *.py | sed -i -- 's/import .LFRequest/from . import LFRequest/g' *.py | ||||||
| sed -i -- 's/import .LFUtils/from . import LFUtils/g' *.py | sed -i -- 's/import .LFUtils/from . import LFUtils/g' *.py | ||||||
| sed -i -- 's/LANforge.LFUtils./LFUtils./g' *.py | sed -i -- 's/LANforge.LFUtils./LFUtils./g' *.py | ||||||
|  | sed -i -- 's/lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")/from .lfcli_base import LFCliBase/g' *.py | ||||||
|  | sed -i -- 's/LFRequest = importlib.import_module("py-json.LANforge.LFRequest")/from .LFRequest import LFRequest/g' *.py | ||||||
|  | sed -i -- 's/LFRequest.LFRequest/LFRequest/g' *.py | ||||||
|  | sed -i -- 's/LFCliBase = lfcli_base.LFCliBase/from .lfcli_base import LFCliBase/g' *.py | ||||||
|  |  | ||||||
| #Convert from importlib to pip compliant method | #Convert from importlib to pip compliant method | ||||||
| sed -i -- 's/LFUtils = importlib.import_module("py-json.LFUtils.)/from .LFUtils import debug_printer/g' *.py | sed -i -- 's/LFUtils = importlib.import_module("py-json.LFUtils.)/from .LFUtils import debug_printer/g' *.py | ||||||
| @@ -390,18 +398,56 @@ sed -i -- 's/LFUtils.debug_printer/debug_printer/g' *.py | |||||||
| sed -i -- 's/LFRequest = importlib.import_module("py-json.LFRequest.)/from .LFRequest import debug_printer/g' *.py | sed -i -- 's/LFRequest = importlib.import_module("py-json.LFRequest.)/from .LFRequest import debug_printer/g' *.py | ||||||
| sed -i -- 's/lanforge-scripts/lanforge_scripts/g' *.py | sed -i -- 's/lanforge-scripts/lanforge_scripts/g' *.py | ||||||
| sed -i -- 's/LFUtils.debug_printer/debug_printer/g' *.py | sed -i -- 's/LFUtils.debug_printer/debug_printer/g' *.py | ||||||
|  | sed -i -- 's/lf_json_autogen = importlib.import_module("py-json.LANforge.lf_json_autogen")/from .lf_json_autogen import LFJsonPost/g' *.py | ||||||
|  | sed -i -- 's/LFJsonPost = lf_json_autogen.LFJsonPost/ /g' *.py | ||||||
|  |  | ||||||
| cd ../../py_dashboard | cd ../../py_dashboard | ||||||
|  | echo " | ||||||
|  | from .GrafanaRequest import GrafanaRequest | ||||||
|  | from .InfluxRequest import RecordInflux | ||||||
|  | from .GhostRequest import GhostRequest" > __init__.py | ||||||
| sed -i -- 's/GrafanaRequest = importlib.import_module("py-dashboard.GrafanaRequest")/from .GrafanaRequest import GrafanaRequest/g' *.py | sed -i -- 's/GrafanaRequest = importlib.import_module("py-dashboard.GrafanaRequest")/from .GrafanaRequest import GrafanaRequest/g' *.py | ||||||
| sed -i -- 's/InfluxRequest = importlib.import_module("py-dashboard.InfluxRequest")/from .InfluxRequest import RecordInflux/g' *.py | sed -i -- 's/InfluxRequest = importlib.import_module("py-dashboard.InfluxRequest")/from .InfluxRequest import RecordInflux/g' *.py | ||||||
| sed -i -- 's/RecordInflux = InfluxRequest.RecordInflux/ /g' *.py | sed -i -- 's/RecordInflux = InfluxRequest.RecordInflux/ /g' *.py | ||||||
|  |  | ||||||
| echo "${ARCHIVE}" | echo "${ARCHIVE}" | ||||||
|  | py_modules=(        'ap_ctl' | ||||||
|  |                     'emailHelper' | ||||||
|  |                     'lf_mail' | ||||||
|  |                     'lf_tos_plus_test' | ||||||
|  |                     'lf_tx_power' | ||||||
|  |                     'tos_plus_auto' | ||||||
|  |                     'auto_install_gui' | ||||||
|  |                     'cpu_stats' | ||||||
|  |                     'lf_sniff' | ||||||
|  |                     'lf_tos_test' | ||||||
|  |                     'openwrt_ctl' | ||||||
|  |                     'stationStressTest' | ||||||
|  |                     'wifi_ctl_9800_3504') | ||||||
| if [[ $ARCHIVE -eq 1 ]]; then | if [[ $ARCHIVE -eq 1 ]]; then | ||||||
|   echo "Saving archive to ${TARGET_DIR}" |   echo "Saving archive to ${TARGET_DIR}" | ||||||
|   cd ../ |   cd .. | ||||||
|   tar cvzf ${TARGET_DIR}/lanforge_scripts.tar.gz . |   mkdir lanforge_scripts | ||||||
|   zip ${TARGET_DIR}/lanforge_scripts.zip . |   mv py_json lanforge_scripts | ||||||
|  |   mv py_dashboard lanforge_scripts | ||||||
|  |   mv py_scripts lanforge_scripts | ||||||
|  |   mv label-printer lanforge_scripts/label_printer | ||||||
|  |   for i in "${py_modules[@]}"; do | ||||||
|  |     mv $i lanforge_scripts | ||||||
|  |   done | ||||||
|  |   rm *.pl | ||||||
|  |   rm *.bash | ||||||
|  |   rm -r gui | ||||||
|  |   rm -r json | ||||||
|  |   rm -r LANforge | ||||||
|  |   rm -r __pycache__ | ||||||
|  |   mv *.py lanforge_scripts | ||||||
|  |   mv lanforge_scripts/setup.py . | ||||||
|  |   rm speedtest-cli | ||||||
|  |   rm WlanPro.desktop | ||||||
|  |   mv wifi_diag lanforge_scripts | ||||||
|  |   tar -zcvf ${TARGET_DIR}/lanforge_scripts.tar.gz * | ||||||
|  |   zip ${TARGET_DIR}/lanforge_scripts.zip * | ||||||
| else | else | ||||||
|   echo "Not saving archive" |   echo "Not saving archive" | ||||||
| fi | fi | ||||||
		Reference in New Issue
	
	Block a user
	 Matthew Stidham
					Matthew Stidham