From e95704311ba9a75ba502448bfbfeca684fb200a2 Mon Sep 17 00:00:00 2001
From: SushantBawiskar
Date: Wed, 30 Sep 2020 11:14:10 +0530
Subject: [PATCH] python scripts for wifi diag with pyshark
---
wifi_diag/wifi_diag_python/Dataplot.py | 42 ++
wifi_diag/wifi_diag_python/htmlText.py | 243 ++++++++++++
wifi_diag/wifi_diag_python/scratch.py | 524 +++++++++++++++++++++++++
3 files changed, 809 insertions(+)
create mode 100644 wifi_diag/wifi_diag_python/Dataplot.py
create mode 100644 wifi_diag/wifi_diag_python/htmlText.py
create mode 100644 wifi_diag/wifi_diag_python/scratch.py
diff --git a/wifi_diag/wifi_diag_python/Dataplot.py b/wifi_diag/wifi_diag_python/Dataplot.py
new file mode 100644
index 00000000..5e9ca1b2
--- /dev/null
+++ b/wifi_diag/wifi_diag_python/Dataplot.py
@@ -0,0 +1,42 @@
+import matplotlib.pyplot as plt
+import base64
+from io import BytesIO
+import os
+import datetime
+
+time = (datetime.datetime.now().time())
+name = "WIFI_Diag"
+name += str(time)
+name += "/"
+
+name = name.replace(":","_")
+if not os.path.exists(str(name)):
+ os.makedirs(str(name))
+
+
+class Plot:
+ def __init__(self):
+ # print("In Plot")
+ pass
+
+ def bar(self, datax="", datay=" ", title="Temp", xaxis="xaxis", yaxis="yaxis",figname="temp"):
+ # fig = plt.figure()
+ self.tmpfile = BytesIO()
+
+ plt.xlabel(xaxis)
+ plt.ylabel(yaxis)
+
+ plt.title(title)
+ plt.xticks(rotation=90)
+ plt.rc('xtick', labelsize=8)
+ plt.rc('ytick', labelsize=8)
+ plt.bar(datax, datay)
+ path = plt.savefig(str(name)+str(figname)+".png",bbox_inches='tight')
+ # plt.savefig(str(title)+".png")
+ plt.savefig(self.tmpfile, format='png')
+ self.encoded = base64.b64encode(self.tmpfile.getvalue()).decode('utf-8')
+ # print("self.encoded",path)
+ plt.clf()
+ return str(name)+str(figname)+".png"
+
+
diff --git a/wifi_diag/wifi_diag_python/htmlText.py b/wifi_diag/wifi_diag_python/htmlText.py
new file mode 100644
index 00000000..29d87526
--- /dev/null
+++ b/wifi_diag/wifi_diag_python/htmlText.py
@@ -0,0 +1,243 @@
+import datetime
+import matplotlib.pyplot as plt
+import base64
+from io import BytesIO
+
+html = open("wifi_diag.html", 'w')
+
+def htmlstart():
+ start = """
+
+
+ WIFI Diag Report
+
+
+
+
+
+
+

+
About:
\
+ "+str(Summary)+"
\n"
+
+ html.write(str(tableSummary))
+
+def myUL():
+ html.write("")
+
+
+def htmlSpanBox(Table):
+ tablespan = "- "+str(Table)+"
"
+ html.write(tablespan)
+
+def htmlSpanBox1():
+ tablespan = "- Table
"
+ html.write(tablespan)
+
+def htmltable(Heading,data,image1,image2,image3):
+ # htmlBreak(1)
+ htmlSpanBox(Heading)
+ htmlTableSummary("This is table summary below Objective \n")
+ htmlSpanBox1()
+ html.write("- ")
+ html.write(str(data))
+ html.write("
")
+ htmltableimage(image1,image2,image3)
+
+
+def htmltableimage(image1, image2, image3):
+ if image1 != "0":
+ imagePre = " \
+

+ html.write(image1)
+ imagepost = )
\
+
"
+ html.write(imagepost)
+
+ if image2 != "0":
+ imagePre = " \
+

+ html.write(image2)
+ imagepost = )
\
+
\n"
+ html.write(imagepost)
+
+ if image3 != "0":
+ imagePre = " \
+

+ html.write(image2)
+ imagepost = )
\
+
"
+ html.write(imagepost)
+
+ html.write("
")
+
+
+def closemyUl():
+ html.write("
\n")
+
+
+def htmlclose():
+ data = """
+
+
+