clicking get data with no ip addresses scanned now scans the network then gets data
This commit is contained in:
@@ -133,6 +133,52 @@ async def get_data(ip_list: list):
|
|||||||
await update_ui_with_data("status", "")
|
await update_ui_with_data("status", "")
|
||||||
|
|
||||||
|
|
||||||
|
async def scan_and_get_data(network):
|
||||||
|
await update_ui_with_data("status", "Scanning")
|
||||||
|
network_size = len(network)
|
||||||
|
miner_generator = network.scan_network_generator()
|
||||||
|
await set_progress_bar_len(3 * network_size)
|
||||||
|
progress_bar_len = 0
|
||||||
|
miners = []
|
||||||
|
async for miner in miner_generator:
|
||||||
|
if miner:
|
||||||
|
miners.append(miner)
|
||||||
|
# can output "Identifying" for each found item, but it gets a bit cluttered
|
||||||
|
# and could possibly be confusing for the end user because of timing on
|
||||||
|
# adding the IPs
|
||||||
|
# window["ip_table"].update([["Identifying...", "", "", "", ""] for miner in miners])
|
||||||
|
progress_bar_len += 1
|
||||||
|
asyncio.create_task(update_prog_bar(progress_bar_len))
|
||||||
|
progress_bar_len += network_size - len(miners)
|
||||||
|
asyncio.create_task(update_prog_bar(progress_bar_len))
|
||||||
|
get_miner_genenerator = miner_factory.get_miner_generator(miners)
|
||||||
|
all_miners = []
|
||||||
|
async for found_miner in get_miner_genenerator:
|
||||||
|
all_miners.append(found_miner)
|
||||||
|
all_miners.sort(key=lambda x: x.ip)
|
||||||
|
window["ip_table"].update([[str(miner.ip), "", "", "", ""] for miner in all_miners])
|
||||||
|
progress_bar_len += 1
|
||||||
|
asyncio.create_task(update_prog_bar(progress_bar_len))
|
||||||
|
data_gen = asyncio.as_completed([get_formatted_data(miner) for miner in miners])
|
||||||
|
ip_table_data = window["ip_table"].Values
|
||||||
|
ordered_all_ips = [item[0] for item in ip_table_data]
|
||||||
|
progress_bar_len += network_size - len(miners)
|
||||||
|
await update_ui_with_data("status", "Getting Data")
|
||||||
|
for all_data in data_gen:
|
||||||
|
data_point = await all_data
|
||||||
|
if data_point["IP"] in ordered_all_ips:
|
||||||
|
ip_table_index = ordered_all_ips.index(data_point["IP"])
|
||||||
|
ip_table_data[ip_table_index] = [
|
||||||
|
data_point["IP"], data_point["host"], str(data_point['TH/s']) + " TH/s", data_point["temp"], data_point['user'], str(data_point['wattage']) + " W"
|
||||||
|
]
|
||||||
|
window["ip_table"].update(ip_table_data)
|
||||||
|
progress_bar_len += 1
|
||||||
|
asyncio.create_task(update_prog_bar(progress_bar_len))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def get_formatted_data(ip: ipaddress.ip_address):
|
async def get_formatted_data(ip: ipaddress.ip_address):
|
||||||
miner = await miner_factory.get_miner(ip)
|
miner = await miner_factory.get_miner(ip)
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ import sys
|
|||||||
import PySimpleGUI as sg
|
import PySimpleGUI as sg
|
||||||
|
|
||||||
from cfg_util.layout import window, generate_config_layout
|
from cfg_util.layout import window, generate_config_layout
|
||||||
from cfg_util.func.miners import scan_network, send_config, miner_light, get_data, generate_config, import_config
|
from cfg_util.func.miners import scan_network, send_config, miner_light, get_data, generate_config, import_config, \
|
||||||
|
scan_and_get_data
|
||||||
from cfg_util.func.files import import_iplist, import_config_file, export_iplist, export_config_file
|
from cfg_util.func.files import import_iplist, import_config_file, export_iplist, export_config_file
|
||||||
from cfg_util.func.ui import sort_data
|
from cfg_util.func.ui import sort_data
|
||||||
|
|
||||||
@@ -53,6 +54,14 @@ async def ui():
|
|||||||
if event == "export_file_config":
|
if event == "export_file_config":
|
||||||
asyncio.create_task(export_config_file(value['file_config'], value["config"]))
|
asyncio.create_task(export_config_file(value['file_config'], value["config"]))
|
||||||
if event == "get_data":
|
if event == "get_data":
|
||||||
|
if len(window["ip_table"].Values) == 0:
|
||||||
|
if len(value['miner_network'].split("/")) > 1:
|
||||||
|
network = value['miner_network'].split("/")
|
||||||
|
miner_network = MinerNetwork(ip_addr=network[0], mask=network[1])
|
||||||
|
else:
|
||||||
|
miner_network = MinerNetwork(value['miner_network'])
|
||||||
|
asyncio.create_task(scan_and_get_data(miner_network))
|
||||||
|
else:
|
||||||
asyncio.create_task(get_data([window["ip_table"].Values[item][0] for item in value["ip_table"]]))
|
asyncio.create_task(get_data([window["ip_table"].Values[item][0] for item in value["ip_table"]]))
|
||||||
if event == "generate_config":
|
if event == "generate_config":
|
||||||
await generate_config_ui()
|
await generate_config_ui()
|
||||||
|
|||||||
Reference in New Issue
Block a user