added exporting a report from bad board utility
This commit is contained in:
BIN
requirements.txt
BIN
requirements.txt
Binary file not shown.
@@ -9,6 +9,7 @@ def disable_buttons(func):
|
|||||||
"select_all_ips",
|
"select_all_ips",
|
||||||
"refresh_data",
|
"refresh_data",
|
||||||
"open_in_web",
|
"open_in_web",
|
||||||
|
"save_report_button",
|
||||||
]
|
]
|
||||||
|
|
||||||
# handle the inner function that the decorator is wrapping
|
# handle the inner function that the decorator is wrapping
|
||||||
|
|||||||
@@ -1,11 +1,49 @@
|
|||||||
import ipaddress
|
import ipaddress
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import xlsxwriter
|
||||||
|
|
||||||
import aiofiles
|
import aiofiles
|
||||||
|
|
||||||
from tools.bad_board_util.func.ui import update_ui_with_data
|
from tools.bad_board_util.func.ui import update_ui_with_data
|
||||||
from tools.bad_board_util.layout import window
|
from tools.bad_board_util.layout import window
|
||||||
|
from tools.bad_board_util.func.decorators import disable_buttons
|
||||||
|
|
||||||
|
|
||||||
|
@disable_buttons
|
||||||
|
async def save_report(file_location):
|
||||||
|
data = []
|
||||||
|
workbook = xlsxwriter.Workbook(file_location)
|
||||||
|
sheet = workbook.add_worksheet()
|
||||||
|
for line in window["ip_table"].Values:
|
||||||
|
data.append([line[0], line[1], line[2], line[3], line[5], line[7]])
|
||||||
|
|
||||||
|
data = sorted(data, reverse=True, key=lambda x: x[2])
|
||||||
|
|
||||||
|
headers = [
|
||||||
|
"IP",
|
||||||
|
"Miner Model",
|
||||||
|
"Total Chip Count",
|
||||||
|
"Left Board Chips",
|
||||||
|
"Center Board Chips",
|
||||||
|
"Right Board Chips",
|
||||||
|
]
|
||||||
|
print(data)
|
||||||
|
row = 0
|
||||||
|
col = 0
|
||||||
|
for item in headers:
|
||||||
|
sheet.write(row, col, item)
|
||||||
|
col += 1
|
||||||
|
|
||||||
|
row = 1
|
||||||
|
for line in data:
|
||||||
|
col = 0
|
||||||
|
for point in line:
|
||||||
|
sheet.write(row, col, point)
|
||||||
|
col += 1
|
||||||
|
row += 1
|
||||||
|
|
||||||
|
workbook.close()
|
||||||
|
|
||||||
|
|
||||||
async def import_iplist(file_location):
|
async def import_iplist(file_location):
|
||||||
|
|||||||
@@ -29,6 +29,12 @@ layout = [
|
|||||||
sg.Button("ALL", key="select_all_ips"),
|
sg.Button("ALL", key="select_all_ips"),
|
||||||
sg.Button("REFRESH DATA", key="refresh_data"),
|
sg.Button("REFRESH DATA", key="refresh_data"),
|
||||||
sg.Button("OPEN IN WEB", key="open_in_web"),
|
sg.Button("OPEN IN WEB", key="open_in_web"),
|
||||||
|
sg.Input(key="save_report", visible=False, enable_events=True),
|
||||||
|
sg.SaveAs(
|
||||||
|
"SAVE REPORT",
|
||||||
|
key="save_report_button",
|
||||||
|
file_types=(("Excel Files", "*.xlsx"),),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
sg.Table(
|
sg.Table(
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import sys
|
import sys
|
||||||
import PySimpleGUI as sg
|
import PySimpleGUI as sg
|
||||||
|
import xlsxwriter
|
||||||
|
|
||||||
from tools.bad_board_util.layout import window
|
from tools.bad_board_util.layout import window
|
||||||
from tools.bad_board_util.func.miners import refresh_data, scan_and_get_data
|
from tools.bad_board_util.func.miners import refresh_data, scan_and_get_data
|
||||||
from tools.bad_board_util.func.files import import_iplist, export_iplist
|
from tools.bad_board_util.func.files import import_iplist, export_iplist, save_report
|
||||||
from tools.bad_board_util.func.ui import sort_data, copy_from_table, table_select_all
|
from tools.bad_board_util.func.ui import sort_data, copy_from_table, table_select_all
|
||||||
|
|
||||||
from network import MinerNetwork
|
from network import MinerNetwork
|
||||||
@@ -36,6 +37,9 @@ async def ui():
|
|||||||
else:
|
else:
|
||||||
miner_network = MinerNetwork(value["miner_network"])
|
miner_network = MinerNetwork(value["miner_network"])
|
||||||
asyncio.create_task(scan_and_get_data(miner_network))
|
asyncio.create_task(scan_and_get_data(miner_network))
|
||||||
|
if event == "save_report":
|
||||||
|
if not value["save_report"] == "":
|
||||||
|
asyncio.create_task(save_report(value["save_report"]))
|
||||||
if event == "select_all_ips":
|
if event == "select_all_ips":
|
||||||
if len(value["ip_table"]) == len(window["ip_table"].Values):
|
if len(value["ip_table"]) == len(window["ip_table"].Values):
|
||||||
window["ip_table"].update(select_rows=())
|
window["ip_table"].update(select_rows=())
|
||||||
|
|||||||
Reference in New Issue
Block a user