added a progress bar when getting data
This commit is contained in:
@@ -31,7 +31,6 @@ async def scan_network(network):
|
|||||||
await update_ui_with_data("status", "Scanning")
|
await update_ui_with_data("status", "Scanning")
|
||||||
network_size = len(network)
|
network_size = len(network)
|
||||||
miner_generator = network.scan_network_generator()
|
miner_generator = network.scan_network_generator()
|
||||||
print(2*network_size)
|
|
||||||
window["progress"].Update(0, max=2*network_size)
|
window["progress"].Update(0, max=2*network_size)
|
||||||
progress_bar_len = 0
|
progress_bar_len = 0
|
||||||
miners = []
|
miners = []
|
||||||
@@ -48,7 +47,7 @@ async def scan_network(network):
|
|||||||
all_miners.append(found_miner)
|
all_miners.append(found_miner)
|
||||||
progress_bar_len += 1
|
progress_bar_len += 1
|
||||||
asyncio.create_task(update_prog_bar(progress_bar_len))
|
asyncio.create_task(update_prog_bar(progress_bar_len))
|
||||||
|
all_miners.sort(key=lambda x: x.ip)
|
||||||
window["ip_list"].update([str(miner.ip) for miner in all_miners])
|
window["ip_list"].update([str(miner.ip) for miner in all_miners])
|
||||||
await update_ui_with_data("ip_count", str(len(all_miners)))
|
await update_ui_with_data("ip_count", str(len(all_miners)))
|
||||||
await update_ui_with_data("status", "")
|
await update_ui_with_data("status", "")
|
||||||
@@ -157,8 +156,17 @@ async def export_config_file(file_location, config):
|
|||||||
async def get_data(ip_list: list):
|
async def get_data(ip_list: list):
|
||||||
await update_ui_with_data("status", "Getting Data")
|
await update_ui_with_data("status", "Getting Data")
|
||||||
ips = [ipaddress.ip_address(ip) for ip in ip_list]
|
ips = [ipaddress.ip_address(ip) for ip in ip_list]
|
||||||
ips.sort()
|
window["progress"].Update(0, max=len(ips))
|
||||||
data = await asyncio.gather(*[get_formatted_data(miner) for miner in ips])
|
progress_bar_len = 0
|
||||||
|
data_gen = asyncio.as_completed([get_formatted_data(miner) for miner in ips])
|
||||||
|
data = []
|
||||||
|
for all_data in data_gen:
|
||||||
|
data.append(await all_data)
|
||||||
|
progress_bar_len += 1
|
||||||
|
asyncio.create_task(update_prog_bar(progress_bar_len))
|
||||||
|
|
||||||
|
data.sort(key=lambda x: ipaddress.ip_address(x['IP']))
|
||||||
|
|
||||||
total_hr = round(sum(d.get('TH/s', 0) for d in data), 2)
|
total_hr = round(sum(d.get('TH/s', 0) for d in data), 2)
|
||||||
window["hr_total"].update(f"{total_hr} TH/s")
|
window["hr_total"].update(f"{total_hr} TH/s")
|
||||||
window["hr_list"].update(disabled=False)
|
window["hr_list"].update(disabled=False)
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ class MinerFactory:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.miners = {}
|
self.miners = {}
|
||||||
|
|
||||||
async def get_miner_generator(self, found_ips):
|
async def get_miner_generator(self, ips: list):
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
scan_tasks = []
|
scan_tasks = []
|
||||||
for miner in found_ips:
|
for miner in ips:
|
||||||
scan_tasks.append(loop.create_task(self.get_miner(miner)))
|
scan_tasks.append(loop.create_task(self.get_miner(miner)))
|
||||||
scanned = asyncio.as_completed(scan_tasks)
|
scanned = asyncio.as_completed(scan_tasks)
|
||||||
for miner in scanned:
|
for miner in scanned:
|
||||||
|
|||||||
Reference in New Issue
Block a user