mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-11-04 04:38:02 +00:00 
			
		
		
		
	lf_renewals.py : checkpoint part of intial checkin
Signed-off-by: Chuck SmileyRekiere <chuck.smileyrekiere@candelatech.com>
This commit is contained in:
		@@ -43,6 +43,8 @@ import csv
 | 
				
			|||||||
import shutil
 | 
					import shutil
 | 
				
			||||||
import os.path
 | 
					import os.path
 | 
				
			||||||
import xlsxwriter
 | 
					import xlsxwriter
 | 
				
			||||||
 | 
					import re
 | 
				
			||||||
 | 
					import pandas as pd
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class lf_renewals():
 | 
					class lf_renewals():
 | 
				
			||||||
@@ -56,6 +58,7 @@ class lf_renewals():
 | 
				
			|||||||
          self.stdout_log = ""
 | 
					          self.stdout_log = ""
 | 
				
			||||||
          self.stderr_log_txt = ""
 | 
					          self.stderr_log_txt = ""
 | 
				
			||||||
          self.stderr_log = ""
 | 
					          self.stderr_log = ""
 | 
				
			||||||
 | 
					          self.dataframe = ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
     def get_data(self):
 | 
					     def get_data(self):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -63,11 +66,11 @@ class lf_renewals():
 | 
				
			|||||||
          if self.outfile is not None:
 | 
					          if self.outfile is not None:
 | 
				
			||||||
               self.stdout_log_txt = self.outfile
 | 
					               self.stdout_log_txt = self.outfile
 | 
				
			||||||
               self.stdout_log_txt = self.stdout_log_txt + "-{}-stdout.txt".format("test")
 | 
					               self.stdout_log_txt = self.stdout_log_txt + "-{}-stdout.txt".format("test")
 | 
				
			||||||
               self.stdout_log = open(self.stdout_log_txt, 'a')
 | 
					               self.stdout_log = open(self.stdout_log_txt, 'w+')
 | 
				
			||||||
               self.stderr_log_txt = self.outfile
 | 
					               self.stderr_log_txt = self.outfile
 | 
				
			||||||
               self.stderr_log_txt = self.stderr_log_txt + "-{}-stderr.txt".format("test")                    
 | 
					               self.stderr_log_txt = self.stderr_log_txt + "-{}-stderr.txt".format("test")                    
 | 
				
			||||||
               #self.logger.info("stderr_log_txt: {}".format(stderr_log_txt))
 | 
					               #self.logger.info("stderr_log_txt: {}".format(stderr_log_txt))
 | 
				
			||||||
               self.stderr_log = open(self.stderr_log_txt, 'a')
 | 
					               self.stderr_log = open(self.stderr_log_txt, 'w+')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
               print("Names {} {}".format(self.stdout_log.name, self.stderr_log.name))
 | 
					               print("Names {} {}".format(self.stdout_log.name, self.stderr_log.name))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -87,6 +90,26 @@ class lf_renewals():
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
          return self.stdout_log_txt
 | 
					          return self.stdout_log_txt
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					     def preprocess_data(self):
 | 
				
			||||||
 | 
					          pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					     # this method uses pandas dataframe - will use for data manipulation, 
 | 
				
			||||||
 | 
					     # the data mainupulation may be done in other manners
 | 
				
			||||||
 | 
					     def datafile_to_dataframe(self):
 | 
				
			||||||
 | 
					          # note the error_bad_lines=False will miss one of the lines 
 | 
				
			||||||
 | 
					          try:
 | 
				
			||||||
 | 
					               self.dataframe = pd.read_csv(self.stdout_log_txt, delimiter = [':'])
 | 
				
			||||||
 | 
					          except:
 | 
				
			||||||
 | 
					               print("one of the files may have a SN: in it need to correct ")
 | 
				
			||||||
 | 
					               self.dataframe = pd.read_csv(self.stdout_log_txt, delimiter = ':', error_bad_lines=False)
 | 
				
			||||||
 | 
					          #print(self.dataframe)
 | 
				
			||||||
 | 
					          print("saving data to .csv")
 | 
				
			||||||
 | 
					          # this removes the extention of .txt
 | 
				
			||||||
 | 
					          renewals_csv= self.stdout_log_txt[:-4]
 | 
				
			||||||
 | 
					          renewals_csv = renewals_csv + ".csv"
 | 
				
			||||||
 | 
					          renewals_csv = self.dataframe.to_csv(renewals_csv,mode='w',index=False)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def main():
 | 
					def main():
 | 
				
			||||||
    # arguments
 | 
					    # arguments
 | 
				
			||||||
    parser = argparse.ArgumentParser(
 | 
					    parser = argparse.ArgumentParser(
 | 
				
			||||||
@@ -112,6 +135,8 @@ show renewas
 | 
				
			|||||||
    renewals = lf_renewals()
 | 
					    renewals = lf_renewals()
 | 
				
			||||||
    output_file = renewals.get_data()
 | 
					    output_file = renewals.get_data()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    renewals.datafile_to_dataframe()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    print("output file: {}".format(str(output_file)))
 | 
					    print("output file: {}".format(str(output_file)))
 | 
				
			||||||
    print("END lf_renewals.py")
 | 
					    print("END lf_renewals.py")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user