mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-10-31 18:58:01 +00:00 
			
		
		
		
	 1d7578251c
			
		
	
	1d7578251c
	
	
	
		
			
			- 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>
		
	
		
			
				
	
	
		
			62 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			62 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
| #!/usr/bin/env python3
 | |
| import sys
 | |
| import os
 | |
| import importlib
 | |
| from pathlib import Path
 | |
| import argparse
 | |
| 
 | |
| if 'lanforge-scripts' not in sys.path:
 | |
|     sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../")))
 | |
| 
 | |
| cv_test_manager = importlib.import_module("lanforge-scripts.py-json.cv_test_manager")
 | |
| cv_add_base_parser = cv_test_manager.cv_add_base_parser
 | |
| cv_base_adjust_parser = cv_test_manager.cv_base_adjust_parser
 | |
| InfluxRequest = importlib.import_module("lanforge-scripts.py-dashboard.InfluxRequest")
 | |
| RecordInflux = InfluxRequest.RecordInflux
 | |
| influx_add_parser_args = InfluxRequest.influx_add_parser_args
 | |
| 
 | |
| class CSVtoInflux:
 | |
|     def __init__(self,
 | |
|                  influx_host,
 | |
|                  influx_port,
 | |
|                  influx_org,
 | |
|                  influx_token,
 | |
|                  influx_bucket,
 | |
|                  path):
 | |
|         self.path = path
 | |
|         self.influxdb = RecordInflux(_influx_host=influx_host,
 | |
|                                      _influx_port=influx_port,
 | |
|                                      _influx_org=influx_org,
 | |
|                                      _influx_token=influx_token,
 | |
|                                      _influx_bucket=influx_bucket)
 | |
| 
 | |
|     def glob(self):
 | |
|         path = Path(self.path)
 | |
|         self.kpi_list = list(path.glob('**/kpi.csv'))
 | |
|         for kpi in self.kpi_list:
 | |
|             self.influxdb.RecordInflux.csv_to_influx(kpi)
 | |
| 
 | |
| 
 | |
| def main():
 | |
|     parser = argparse.ArgumentParser()
 | |
|     cv_add_base_parser(parser)
 | |
| 
 | |
|     parser.add_argument('--path', action='append')
 | |
| 
 | |
|     args = parser.parse_args()
 | |
| 
 | |
|     cv_base_adjust_parser(args)
 | |
| 
 | |
|     csvtoinflux = CSVtoInflux(args.influx_host,
 | |
|                               args.influx_port,
 | |
|                               args.influx_org,
 | |
|                               args.influx_token,
 | |
|                               args.influx_bucket,
 | |
|                               args.path)
 | |
| 
 | |
|     csvtoinflux.glob()
 | |
| 
 | |
| 
 | |
| if __name__ == "__main__":
 | |
|     main()
 |