updated some formatting and improved pool return format

This commit is contained in:
UpstreamData
2022-05-05 13:02:00 -06:00
parent ac3ff7a63e
commit 801cfc4ff8
7 changed files with 51 additions and 33 deletions

View File

@@ -152,7 +152,7 @@ class BMMiner(BaseMiner):
hr = summary.get("SUMMARY")
if hr:
if len(hr) > 0:
hr = hr[0].get("GHS av")
hr = hr[0].get("GHS 5s")
if hr:
data["Hashrate"] = round(hr / 1000, 2)
@@ -191,6 +191,10 @@ class BMMiner(BaseMiner):
quota = f"{pool_1_quota}/{pool_2_quota}"
if pool_1:
if pool_1.startswith("stratum+tcp://"):
pool_1.replace("stratum+tcp://", "")
if pool_1.startswith("stratum2+tcp://"):
pool_1.replace("stratum2+tcp://", "")
data["Pool 1"] = pool_1
if pool_1_user:
@@ -198,6 +202,10 @@ class BMMiner(BaseMiner):
data["Pool User"] = pool_1_user
if pool_2:
if pool_2.startswith("stratum+tcp://"):
pool_2.replace("stratum+tcp://", "")
if pool_2.startswith("stratum2+tcp://"):
pool_2.replace("stratum2+tcp://", "")
data["Pool 2"] = pool_2
if pool_2_user:

View File

@@ -262,7 +262,7 @@ class BOSMiner(BaseMiner):
hr = summary.get("SUMMARY")
if hr:
if len(hr) > 0:
hr = hr[0].get("MHS av")
hr = hr[0].get("MHS 5s")
if hr:
data["Hashrate"] = round(hr / 1000000, 2)
@@ -300,6 +300,8 @@ class BOSMiner(BaseMiner):
quota = f"{pool_1_quota}/{pool_2_quota}"
if pool_1:
pool_1 = pool_1.replace("stratum+tcp://", "")
pool_1 = pool_1.replace("stratum2+tcp://", "")
data["Pool 1"] = pool_1
if pool_1_user:
@@ -307,6 +309,8 @@ class BOSMiner(BaseMiner):
data["Pool User"] = pool_1_user
if pool_2:
pool_2 = pool_2.replace("stratum+tcp://", "")
pool_2 = pool_2.replace("stratum2+tcp://", "")
data["Pool 2"] = pool_2
if pool_2_user:

View File

@@ -108,7 +108,7 @@ class BTMiner(BaseMiner):
summary_data = summary.get("SUMMARY")
if summary_data:
if len(summary_data) > 0:
hr = summary_data[0].get("MHS av")
hr = summary_data[0].get("MHS 5s")
if hr:
data["Hashrate"] = round(hr / 1000000, 2)
@@ -151,6 +151,10 @@ class BTMiner(BaseMiner):
quota = f"{pool_1_quota}/{pool_2_quota}"
if pool_1:
if pool_1.startswith("stratum+tcp://"):
pool_1.replace("stratum+tcp://", "")
if pool_1.startswith("stratum2+tcp://"):
pool_1.replace("stratum2+tcp://", "")
data["Pool 1"] = pool_1
if pool_1_user:
@@ -158,6 +162,10 @@ class BTMiner(BaseMiner):
data["Pool User"] = pool_1_user
if pool_2:
if pool_2.startswith("stratum+tcp://"):
pool_2.replace("stratum+tcp://", "")
if pool_2.startswith("stratum2+tcp://"):
pool_2.replace("stratum2+tcp://", "")
data["Pool 2"] = pool_2
if pool_2_user:

View File

@@ -127,7 +127,7 @@ class CGMiner(BaseMiner):
hr = summary.get("SUMMARY")
if hr:
if len(hr) > 0:
hr = hr[0].get("GHS av")
hr = hr[0].get("GHS 5s")
if hr:
data["Hashrate"] = round(hr / 1000, 2)
@@ -166,6 +166,10 @@ class CGMiner(BaseMiner):
quota = f"{pool_1_quota}/{pool_2_quota}"
if pool_1:
if pool_1.startswith("stratum+tcp://"):
pool_1.replace("stratum+tcp://", "")
if pool_1.startswith("stratum2+tcp://"):
pool_1.replace("stratum2+tcp://", "")
data["Pool 1"] = pool_1
if pool_1_user:
@@ -173,6 +177,10 @@ class CGMiner(BaseMiner):
data["Pool User"] = pool_1_user
if pool_2:
if pool_2.startswith("stratum+tcp://"):
pool_2.replace("stratum+tcp://", "")
if pool_2.startswith("stratum2+tcp://"):
pool_2.replace("stratum2+tcp://", "")
data["Pool 2"] = pool_2
if pool_2_user:

View File

@@ -6,9 +6,7 @@ from io import BytesIO
from PIL import ImageTk, Image
from tools.cfg_util.cfg_util_qt.imgs import FAULT_LIGHT
from tools.cfg_util.cfg_util_qt.tables import clear_tables
from tools.cfg_util.cfg_util_qt.scan import scan_miners
from network import MinerNetwork
from tools.cfg_util.cfg_util_qt.scan import btn_scan
from tools.cfg_util.cfg_util_qt.layout import window
import tkinter as tk
@@ -18,24 +16,13 @@ sg.set_options(font=("Liberation Mono", 10))
async def main():
window.read(0)
window["scan_table"].Widget.column(2, anchor=tk.W)
# tree = window["command_table"]
# tree_widget = tree.Widget
# index = 0
# iid = f"I{str(index + 1).rjust(3, '0')}"
# img = ImageTk.PhotoImage(Image.open(BytesIO(base64.b64decode(FAULT_LIGHT))))
# tree_widget.item(iid, image=img)
# clear_tables()
while True:
event, value = window.read(0)
if event in (None, "Close", sg.WIN_CLOSED):
sys.exit()
if event == "btn_scan":
network = MinerNetwork("192.168.1.0")
if value["scan_ip"]:
ip, mask = value["scan_ip"].split("/")
network = MinerNetwork(ip, mask=mask)
asyncio.create_task(scan_miners(network))
await btn_scan(value["scan_ip"])
if event == "__TIMEOUT__":
await asyncio.sleep(0)

View File

@@ -14,7 +14,7 @@ TABLE_HEADERS = {
"CMD": ["IP", "Model", "Command Output"],
"POOLS": [
"IP",
"Model",
# "Model",
"Split",
"Pool 1",
"Pool 1 User",
@@ -134,8 +134,6 @@ def get_scan_layout():
def get_command_layout():
data = sg.TreeData()
data.insert("", 0, "", ["192.168.168.168", "S19j Pro (BOS)", ""], icon=LIGHT)
data.insert("", 1, "", ["192.168.168.168", "S19j Pro (BOS)", ""], icon=LIGHT)
col_widths = [
IP_COL_WIDTH,
MODEL_COL_WIDTH,
@@ -184,17 +182,14 @@ def get_command_layout():
def get_pools_layout():
pool_col_width = int(
(TABLE_TOTAL_WIDTH - (IP_COL_WIDTH + MODEL_COL_WIDTH + SPLIT_COL_WIDTH)) / 4
)
pool_col_width = int((TABLE_TOTAL_WIDTH - (IP_COL_WIDTH + SPLIT_COL_WIDTH)) / 4)
col_widths = [
IP_COL_WIDTH,
MODEL_COL_WIDTH,
SPLIT_COL_WIDTH,
pool_col_width,
pool_col_width,
pool_col_width,
pool_col_width,
pool_col_width + 5,
pool_col_width - 5,
pool_col_width + 5,
pool_col_width - 5,
]
pools_layout = [
[

View File

@@ -12,7 +12,15 @@ import logging
progress_bar_len = 0
async def scan_miners(network: MinerNetwork):
async def btn_scan(scan_ip: str):
network = MinerNetwork("192.168.1.0")
if scan_ip:
ip, mask = scan_ip.split("/")
network = MinerNetwork(ip, mask=mask)
asyncio.create_task(_scan_miners(network))
async def _scan_miners(network: MinerNetwork):
clear_tables()
scan_generator = network.scan_network_generator()
MinerFactory().clear_cached_miners()
@@ -43,10 +51,10 @@ async def scan_miners(network: MinerNetwork):
await update_prog_bar(progress_bar_len)
progress_bar_len += network_size - len(resolved_miners)
await update_prog_bar(progress_bar_len)
await get_miners_data(resolved_miners)
await _get_miners_data(resolved_miners)
async def get_miners_data(miners: list):
async def _get_miners_data(miners: list):
global progress_bar_len
data_generator = asyncio.as_completed([_get_data(miner) for miner in miners])
miner_data = [{"IP": str(miner.ip)} for miner in miners]