report generation added for dynamic data

pick 0429552 conflicts resolved in lf_graph changes
This commit is contained in:
anil-tegala
2021-07-13 19:18:28 +05:30
parent d50ed322f5
commit bcbaff86e6
5 changed files with 378 additions and 450 deletions

View File

@@ -9,7 +9,7 @@ SETUP:
/lanforge/html-reports directory needs to be present or output generated in local file
EXAMPLE:
see: /py-scritps/lf_csv_test.py for example
see: /py-scritps/lf_report_test.py for example
COPYWRITE
Copyright 2021 Candela Technologies Inc
@@ -41,7 +41,7 @@ class LfCSV:
df[self.columns[i]] = self.rows[i]
csv_df = pd.DataFrame(df)
print(csv_df)
csv_df.to_csv(self.filename, encoding='utf-8', na_rep='NA', float_format='%.2f')
csv_df.to_csv(self.filename, index=False, encoding='utf-8', na_rep='NA', float_format='%.2f')
if __name__ == "__main__":

View File

@@ -52,7 +52,7 @@ class lf_bar_graph():
_xticks_font = None,
_grp_title = "",
_dpi=96,
_enable_csv=True):
_enable_csv=False):
self.data_set = _data_set
self.xaxis_name = _xaxis_name
@@ -304,11 +304,11 @@ class lf_horizontal_stacked_graph():
plt.savefig("%s.png" % self.graph_image_name, dpi=96)
plt.close()
print("{}.png".format(self.graph_image_name))
# if self.enable_csv:
# self.lf_csv.columns = self.label
# self.lf_csv.rows = self.data_set
# self.lf_csv.filename = f"{self.graph_image_name}.csv"
# self.lf_csv.generate_csv()
if self.enable_csv:
self.lf_csv.columns = self.label
self.lf_csv.rows = self.data_set
self.lf_csv.filename = f"{self.graph_image_name}.csv"
self.lf_csv.generate_csv()
return "%s.png" % self.graph_image_name

View File

@@ -81,6 +81,7 @@ class lf_report():
self.footer_html = ""
self.graph_titles=""
self.graph_image=""
self.csv_file_name=""
self.html = ""
self.custom_html = ""
self.objective = _obj
@@ -146,8 +147,13 @@ class lf_report():
print("graph_src_file: {}".format(graph_src_file))
print("graph_dst_file: {}".format(graph_dst_file))
shutil.move(graph_src_file, graph_dst_file)
def move_csv_file(self):
csv_src_file = str(self.fil)
csv_src_file = str(self.csv_file_name)
csv_dst_file = str(self.path_date_time)+'/'+str(self.csv_file_name)
print("csv_src_file: {}".format(csv_src_file))
print("csv_dst_file: {}".format(csv_dst_file))
shutil.move(csv_src_file, csv_dst_file)
def set_path(self,_path):
self.path = _path
@@ -187,6 +193,11 @@ class lf_report():
def set_graph_title(self,_graph_title):
self.graph_title = _graph_title
# sets the csv file name as graph title
def set_csv_filename(self, _graph_title):
fname, ext = os.path.splitext(_graph_title)
self.csv_file_name = fname + ".csv"
# The _date is set when class is enstanciated / created so this set_date should be used with caution, used to synchronize results
def set_date(self,_date):
self.date = _date
@@ -275,7 +286,6 @@ class lf_report():
self.write_output_pdf = "{}/{}-{}".format(self.path_date_time,self.date,self.output_pdf)
pdfkit.from_file(self.write_output_html, self.write_output_pdf, options=options)
def generate_report(self):
self.write_html()
self.write_pdf()
@@ -351,7 +361,7 @@ class lf_report():
os.mkdir(self.path_date_time)
def build_table(self):
self.dataframe_html = self.dataframe.to_html(index=False, justify='left') # have the index be able to be passed in.
self.dataframe_html = self.dataframe.to_html(index=False, justify='center') # have the index be able to be passed in.
self.html += self.dataframe_html
def test_setup_table(self,test_setup_data, value):

View File

@@ -36,7 +36,7 @@ if __name__ == "__main__":
'radios': [1, 1, 2, 2, 6, 9, 3],
'MIMO': ['N', 'N', 'N', 'Y', 'Y', 'Y', 'Y'],
'stations': [200, 64, 200, 128, 384, 72, 192],
'mbps': [300, 300, 300, 10000, 10000, 10000, 10000]
'1 mbps': [300, 300, 300, 10000, 10000, 10000, 10000]
})
print(dataframe)

File diff suppressed because it is too large Load Diff