Browse Source

logreader bug fixes and updats

Bernhard Buhl 5 years ago
parent
commit
affd6102b6
6 changed files with 223 additions and 141 deletions
  1. 1 0
      copy_from_server.cmd
  2. 0 0
      dist/log/init_dev.ini
  3. 184 132
      dist/log/log_summary.csv
  4. 0 4
      dist/log_summary.csv
  5. 2 0
      dist/te/log_summary.csv
  6. 36 5
      log_reporter.py

+ 1 - 0
copy_from_server.cmd

@@ -0,0 +1 @@
+scp -r -P 2222 landscape@94.237.82.174:/opt/api_test/log*.log ./dist/log/.

init_dev.ini → dist/log/init_dev.ini


File diff suppressed because it is too large
+ 184 - 132
dist/log/log_summary.csv


File diff suppressed because it is too large
+ 0 - 4
dist/log_summary.csv


File diff suppressed because it is too large
+ 2 - 0
dist/te/log_summary.csv


+ 36 - 5
log_reporter.py

@@ -20,6 +20,25 @@ Should read all log*.log-files and output
 import codecs
 import csv
 import glob, os
+import datetime
+import getopt
+import sys
+
+
+def args_read(l_search_parameter):
+    l_args = sys.argv[1:]
+
+    try:
+        opts, args = getopt.getopt(l_args,"d:;",["dir=",
+                                                    ])
+    except getopt.GetoptError as err_det:
+        print ("Error in reading parameters:" + str(err_det))
+        print ("Call with --dir= or without any parameters")
+        sys.exit("Abgebrochen wegen Fehler in Aufrufparametern")
+    if opts:
+        for opt, arg in opts:
+            if l_search_parameter == opt: #in ("-u", "--usage"):
+                return arg
 
 
 def f_get_logfiles_from_dir(l_dir):
@@ -38,6 +57,7 @@ class read_csv():
         self.attribs["file"] = csv.split("\\")[-1]
         self.attribs["start"] = ""
         self.attribs["end"] = ""
+        self.attribs["duration"] = ""
         self.attribs["server"] = ""
         self.attribs["computer"] = ""
         self.attribs["users"] = 0
@@ -87,6 +107,8 @@ class read_csv():
                 # Server:
                 if "set_default: Server:" in l_string:
                     self.attribs["server"] = l_string.split(" ")[-1]
+                elif "Server: " in l_string:
+                    self.attribs["server"] = l_string.split(" ")[-1]
                     
                 if "get_l_users: Users: " in l_string:
                     self.attribs["users"] = int(l_string.split(" ")[-1])    
@@ -99,6 +121,11 @@ class read_csv():
                     
                 if "printreport" in l_string:
                     self.__printreport(l_string)
+                    
+            if len(self.attribs["end"]) > 13 and len(self.attribs["start"]) > 13:
+                self.attribs["duration"] = ( datetime.datetime.strptime(self.attribs["end"], '%Y-%m-%d %H:%M:%S:%f')
+                                             - datetime.datetime.strptime(self.attribs["start"], '%Y-%m-%d %H:%M:%S:%f') )
+                
 
         if self.attribs["mode"] == "":
             self.attribs["mode"] = "allnew"
@@ -169,17 +196,21 @@ def l_export_csvs(l_csvs, l_export_filename):
             for l_row_key, l_row_item in l_csv_in.get_all_attribs().items():
                 if l_row_key == "API-AVG":
                     for n in range(0, 5):
-                        if isint(l_row_item[n]):
-                            l_row_out.append(l_row_item[n])
-                        elif 
+                        #if isinstance(l_row_item[n], int):
+                        l_row_out.append(str(l_row_item[n]).replace(".", ","))
+                        #elif 
                 
                 else:
                     l_row_out.append(l_row_item)
             l_csv_writer.writerow(l_row_out)
             
+
         
-                    
-l_dir = "C:\\Users\\Bernhard\\cs_earthsquad\\CloudStation\\pwa\\Testcases\\API\\ES_API_TEST\\pyAPITest\\dist\\log\\"
+l_dir = args_read("--dir")
+if not l_dir:                    
+    l_dir = "C:\\Users\\Bernhard\\cs_earthsquad\\CloudStation\\pwa\\Testcases\\API\\ES_API_TEST\\pyAPITest\\dist\\log\\"
+else:
+    l_dir = l_dir + "\\"
 
 l_csvs = {}