added export csv button to export all data from the tool
This commit is contained in:
@@ -30,6 +30,27 @@ async def import_iplist(file_location):
|
|||||||
await update_ui_with_data("status", "")
|
await update_ui_with_data("status", "")
|
||||||
|
|
||||||
|
|
||||||
|
async def export_csv(file_location, ip_list_selected):
|
||||||
|
await update_ui_with_data("status", "Exporting")
|
||||||
|
if not os.path.exists(file_location):
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
if ip_list_selected is not None and not ip_list_selected == []:
|
||||||
|
async with aiofiles.open(file_location, mode='w') as file:
|
||||||
|
for item in ip_list_selected:
|
||||||
|
await file.write(str(
|
||||||
|
", ".join([str(part) for part in item])
|
||||||
|
) + "\n")
|
||||||
|
else:
|
||||||
|
async with aiofiles.open(file_location, mode='w') as file:
|
||||||
|
for item in window['ip_table'].Values:
|
||||||
|
await file.write(str(
|
||||||
|
", ".join([str(part) for part in item])
|
||||||
|
) + "\n")
|
||||||
|
await update_ui_with_data("status", "")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def export_iplist(file_location, ip_list_selected):
|
async def export_iplist(file_location, ip_list_selected):
|
||||||
await update_ui_with_data("status", "Exporting")
|
await update_ui_with_data("status", "Exporting")
|
||||||
if not os.path.exists(file_location):
|
if not os.path.exists(file_location):
|
||||||
|
|||||||
@@ -16,18 +16,20 @@ layout = [
|
|||||||
sg.InputText(key='miner_network', do_not_clear=True, size=(115, 1)),
|
sg.InputText(key='miner_network', do_not_clear=True, size=(115, 1)),
|
||||||
sg.Button('Scan', key='scan')],
|
sg.Button('Scan', key='scan')],
|
||||||
|
|
||||||
[sg.Text('IP List File:', size=(9, 1)),
|
|
||||||
sg.Input(key="file_iplist", do_not_clear=True, size=(115, 1)),
|
|
||||||
sg.FileBrowse(),
|
|
||||||
sg.Button('Import', key="import_iplist"),
|
|
||||||
sg.Button('Export', key="export_iplist")],
|
|
||||||
|
|
||||||
[sg.Text('Config File:', size=(9, 1)),
|
[sg.Text('Config File:', size=(9, 1)),
|
||||||
sg.Input(key="file_config", do_not_clear=True, size=(115, 1)),
|
sg.Input(key="file_config", do_not_clear=True, size=(115, 1)),
|
||||||
sg.FileBrowse(),
|
sg.FileBrowse(),
|
||||||
sg.Button('Import', key="import_file_config"),
|
sg.Button('Import', key="import_file_config"),
|
||||||
sg.Button('Export', key="export_file_config")],
|
sg.Button('Export', key="export_file_config")],
|
||||||
|
|
||||||
|
[sg.Text('IP List File:', size=(9, 1)),
|
||||||
|
sg.Input(key="file_iplist", do_not_clear=True, size=(115, 1)),
|
||||||
|
sg.FileBrowse(),
|
||||||
|
sg.Button('Import', key="import_iplist"),
|
||||||
|
sg.Button('Export', key="export_iplist"),
|
||||||
|
sg.Button('Export CSV', key="export_csv")],
|
||||||
|
|
||||||
|
|
||||||
[sg.Column([
|
[sg.Column([
|
||||||
|
|
||||||
[sg.Column([
|
[sg.Column([
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import PySimpleGUI as sg
|
|||||||
from tools.cfg_util.cfg_util_sg.layout import window, generate_config_layout
|
from tools.cfg_util.cfg_util_sg.layout import window, generate_config_layout
|
||||||
from tools.cfg_util.cfg_util_sg.func.miners import send_config, miner_light, refresh_data, generate_config, import_config, \
|
from tools.cfg_util.cfg_util_sg.func.miners import send_config, miner_light, refresh_data, generate_config, import_config, \
|
||||||
scan_and_get_data, restart_miners_backend, reboot_miners
|
scan_and_get_data, restart_miners_backend, reboot_miners
|
||||||
from tools.cfg_util.cfg_util_sg.func.files import import_iplist, import_config_file, export_iplist, export_config_file
|
from tools.cfg_util.cfg_util_sg.func.files import import_iplist, \
|
||||||
|
import_config_file, export_iplist, export_config_file, export_csv
|
||||||
from tools.cfg_util.cfg_util_sg.func.ui import sort_data, copy_from_table
|
from tools.cfg_util.cfg_util_sg.func.ui import sort_data, copy_from_table
|
||||||
|
|
||||||
from network import MinerNetwork
|
from network import MinerNetwork
|
||||||
@@ -54,6 +55,8 @@ async def ui():
|
|||||||
asyncio.create_task(import_iplist(value["file_iplist"]))
|
asyncio.create_task(import_iplist(value["file_iplist"]))
|
||||||
if event == "export_iplist":
|
if event == "export_iplist":
|
||||||
asyncio.create_task(export_iplist(value["file_iplist"], [window['ip_table'].Values[item][0] for item in value['ip_table']]))
|
asyncio.create_task(export_iplist(value["file_iplist"], [window['ip_table'].Values[item][0] for item in value['ip_table']]))
|
||||||
|
if event == "export_csv":
|
||||||
|
asyncio.create_task(export_csv(value["file_iplist"], [window['ip_table'].Values[item] for item in value['ip_table']]))
|
||||||
if event == "send_config":
|
if event == "send_config":
|
||||||
asyncio.create_task(send_config([window['ip_table'].Values[item][0] for item in value['ip_table']], value['config']))
|
asyncio.create_task(send_config([window['ip_table'].Values[item][0] for item in value['ip_table']], value['config']))
|
||||||
if event == "import_file_config":
|
if event == "import_file_config":
|
||||||
|
|||||||
Reference in New Issue
Block a user