reformatted all files to use the Black formatting style
This commit is contained in:
@@ -13,10 +13,15 @@ from tools.cfg_util.cfg_util_sg.ui import ui
|
||||
|
||||
# initialize logger and get settings
|
||||
from logger import logger
|
||||
|
||||
logger.info("Initializing logger for CFG Util.")
|
||||
|
||||
# Fix bug with some whatsminers and asyncio because of a socket not being shut down:
|
||||
if sys.version_info[0] == 3 and sys.version_info[1] >= 8 and sys.platform.startswith('win'):
|
||||
if (
|
||||
sys.version_info[0] == 3
|
||||
and sys.version_info[1] >= 8
|
||||
and sys.platform.startswith("win")
|
||||
):
|
||||
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
||||
|
||||
|
||||
|
||||
@@ -2,23 +2,24 @@ from tools.cfg_util.cfg_util_sg.layout import window
|
||||
|
||||
|
||||
def disable_buttons(func):
|
||||
button_list = ["scan",
|
||||
"import_file_config",
|
||||
"export_file_config",
|
||||
"import_iplist",
|
||||
"export_iplist",
|
||||
"export_csv",
|
||||
"select_all_ips",
|
||||
"refresh_data",
|
||||
"open_in_web",
|
||||
"reboot_miners",
|
||||
"restart_miner_backend",
|
||||
"import_config",
|
||||
"send_config",
|
||||
"light",
|
||||
"generate_config",
|
||||
"send_miner_ssh_command_window",
|
||||
]
|
||||
button_list = [
|
||||
"scan",
|
||||
"import_file_config",
|
||||
"export_file_config",
|
||||
"import_iplist",
|
||||
"export_iplist",
|
||||
"export_csv",
|
||||
"select_all_ips",
|
||||
"refresh_data",
|
||||
"open_in_web",
|
||||
"reboot_miners",
|
||||
"restart_miner_backend",
|
||||
"import_config",
|
||||
"send_config",
|
||||
"light",
|
||||
"generate_config",
|
||||
"send_miner_ssh_command_window",
|
||||
]
|
||||
|
||||
# handle the inner function that the decorator is wrapping
|
||||
async def inner(*args, **kwargs):
|
||||
|
||||
@@ -17,10 +17,15 @@ async def import_iplist(file_location):
|
||||
return
|
||||
else:
|
||||
ip_list = []
|
||||
async with aiofiles.open(file_location, mode='r') as file:
|
||||
async with aiofiles.open(file_location, mode="r") as file:
|
||||
async for line in file:
|
||||
ips = [x.group() for x in re.finditer(
|
||||
"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)", line)]
|
||||
ips = [
|
||||
x.group()
|
||||
for x in re.finditer(
|
||||
"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",
|
||||
line,
|
||||
)
|
||||
]
|
||||
for ip in ips:
|
||||
if ip not in ip_list:
|
||||
ip_list.append(ipaddress.ip_address(ip))
|
||||
@@ -36,33 +41,34 @@ async def export_csv(file_location, ip_list_selected):
|
||||
return
|
||||
else:
|
||||
if ip_list_selected is not None and not ip_list_selected == []:
|
||||
async with aiofiles.open(file_location, mode='w') as file:
|
||||
async with aiofiles.open(file_location, mode="w") as file:
|
||||
for item in ip_list_selected:
|
||||
await file.write(str(
|
||||
", ".join([str(part).rstrip().lstrip() for part in item])
|
||||
) + "\n")
|
||||
await file.write(
|
||||
str(", ".join([str(part).rstrip().lstrip() 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).rstrip().lstrip() for part in item])
|
||||
) + "\n")
|
||||
async with aiofiles.open(file_location, mode="w") as file:
|
||||
for item in window["ip_table"].Values:
|
||||
await file.write(
|
||||
str(", ".join([str(part).rstrip().lstrip() for part in item]))
|
||||
+ "\n"
|
||||
)
|
||||
await update_ui_with_data("status", "")
|
||||
|
||||
|
||||
|
||||
async def export_iplist(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:
|
||||
async with aiofiles.open(file_location, mode="w") as file:
|
||||
for item in ip_list_selected:
|
||||
await file.write(str(item) + "\n")
|
||||
else:
|
||||
async with aiofiles.open(file_location, mode='w') as file:
|
||||
for item in window['ip_table'].Values:
|
||||
async with aiofiles.open(file_location, mode="w") as file:
|
||||
for item in window["ip_table"].Values:
|
||||
await file.write(str(item[0]) + "\n")
|
||||
await update_ui_with_data("status", "")
|
||||
|
||||
@@ -72,7 +78,7 @@ async def import_config_file(file_location):
|
||||
if not os.path.exists(file_location):
|
||||
return
|
||||
else:
|
||||
async with aiofiles.open(file_location, mode='r') as file:
|
||||
async with aiofiles.open(file_location, mode="r") as file:
|
||||
config = await file.read()
|
||||
await update_ui_with_data("config", await bos_config_convert(toml.loads(config)))
|
||||
await update_ui_with_data("status", "")
|
||||
@@ -82,9 +88,9 @@ async def export_config_file(file_location, config):
|
||||
await update_ui_with_data("status", "Exporting")
|
||||
config = toml.dumps(await general_config_convert_bos(config))
|
||||
config = toml.loads(config)
|
||||
config['format']['generator'] = 'upstream_config_util'
|
||||
config['format']['timestamp'] = int(time.time())
|
||||
config["format"]["generator"] = "upstream_config_util"
|
||||
config["format"]["timestamp"] = int(time.time())
|
||||
config = toml.dumps(config)
|
||||
async with aiofiles.open(file_location, mode='w+') as file:
|
||||
async with aiofiles.open(file_location, mode="w+") as file:
|
||||
await file.write(config)
|
||||
await update_ui_with_data("status", "")
|
||||
|
||||
@@ -6,17 +6,24 @@ import logging
|
||||
|
||||
from API import APIError
|
||||
from tools.cfg_util.cfg_util_sg.func.parse_data import safe_parse_api_data
|
||||
from tools.cfg_util.cfg_util_sg.func.ui import update_ui_with_data, update_prog_bar, set_progress_bar_len
|
||||
from tools.cfg_util.cfg_util_sg.func.ui import (
|
||||
update_ui_with_data,
|
||||
update_prog_bar,
|
||||
set_progress_bar_len,
|
||||
)
|
||||
from tools.cfg_util.cfg_util_sg.layout import window
|
||||
from miners.miner_factory import MinerFactory
|
||||
from config.bos import bos_config_convert
|
||||
from tools.cfg_util.cfg_util_sg.func.decorators import disable_buttons
|
||||
from settings import CFG_UTIL_CONFIG_THREADS as CONFIG_THREADS, CFG_UTIL_REBOOT_THREADS as REBOOT_THREADS
|
||||
from settings import (
|
||||
CFG_UTIL_CONFIG_THREADS as CONFIG_THREADS,
|
||||
CFG_UTIL_REBOOT_THREADS as REBOOT_THREADS,
|
||||
)
|
||||
|
||||
|
||||
async def import_config(idx):
|
||||
await update_ui_with_data("status", "Importing")
|
||||
miner_ip = window['ip_table'].Values[idx[0]][0]
|
||||
miner_ip = window["ip_table"].Values[idx[0]][0]
|
||||
logging.debug(f"{miner_ip}: Importing config.")
|
||||
miner = await MinerFactory().get_miner(ipaddress.ip_address(miner_ip))
|
||||
await miner.get_config()
|
||||
@@ -67,10 +74,10 @@ async def miner_light(ips: list):
|
||||
|
||||
|
||||
async def flip_light(ip):
|
||||
ip_list = window['ip_table'].Widget
|
||||
ip_list = window["ip_table"].Widget
|
||||
miner = await MinerFactory().get_miner(ip)
|
||||
index = [item[0] for item in window["ip_table"].Values].index(ip)
|
||||
index_tags = ip_list.item(index + 1)['tags']
|
||||
index_tags = ip_list.item(index + 1)["tags"]
|
||||
if "light" not in index_tags:
|
||||
index_tags.append("light")
|
||||
ip_list.item(index + 1, tags=index_tags)
|
||||
@@ -122,7 +129,8 @@ async def send_miners_ssh_commands(ips: list, command: str, ssh_cmd_window):
|
||||
if str(item["IP"]) in ips:
|
||||
proc_table_index = ips.index(str(item["IP"]))
|
||||
proc_table_data[proc_table_index] = [
|
||||
str(item["IP"]), return_data.replace("\n", " "),
|
||||
str(item["IP"]),
|
||||
return_data.replace("\n", " "),
|
||||
]
|
||||
ssh_cmd_window["ssh_cmd_table"].update(proc_table_data)
|
||||
|
||||
@@ -238,7 +246,10 @@ async def refresh_data(ip_list: list):
|
||||
await update_ui_with_data("hr_total", "")
|
||||
ips = [ipaddress.ip_address(ip) for ip in ip_list]
|
||||
if len(ips) == 0:
|
||||
ips = [ipaddress.ip_address(ip) for ip in [item[0] for item in window["ip_table"].Values]]
|
||||
ips = [
|
||||
ipaddress.ip_address(ip)
|
||||
for ip in [item[0] for item in window["ip_table"].Values]
|
||||
]
|
||||
await set_progress_bar_len(len(ips))
|
||||
progress_bar_len = 0
|
||||
asyncio.create_task(update_prog_bar(progress_bar_len))
|
||||
@@ -258,9 +269,13 @@ async def refresh_data(ip_list: list):
|
||||
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["model"], data_point["host"], str(data_point['TH/s']) + " TH/s ",
|
||||
data_point["IP"],
|
||||
data_point["model"],
|
||||
data_point["host"],
|
||||
str(data_point["TH/s"]) + " TH/s ",
|
||||
data_point["temp"],
|
||||
data_point['user'], str(data_point['wattage']) + " W"
|
||||
data_point["user"],
|
||||
str(data_point["wattage"]) + " W",
|
||||
]
|
||||
window["ip_table"].update(ip_table_data)
|
||||
progress_bar_len += 1
|
||||
@@ -270,8 +285,10 @@ async def refresh_data(ip_list: list):
|
||||
hr_idx = 3
|
||||
for item, _ in enumerate(window["ip_table"].Values):
|
||||
if len(window["ip_table"].Values[item]) > hr_idx:
|
||||
if not window["ip_table"].Values[item][hr_idx] == '':
|
||||
hashrate_list.append(float(window["ip_table"].Values[item][hr_idx].replace(" TH/s ", "")))
|
||||
if not window["ip_table"].Values[item][hr_idx] == "":
|
||||
hashrate_list.append(
|
||||
float(window["ip_table"].Values[item][hr_idx].replace(" TH/s ", ""))
|
||||
)
|
||||
else:
|
||||
hashrate_list.append(0)
|
||||
else:
|
||||
@@ -325,7 +342,7 @@ async def scan_and_get_data(network):
|
||||
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))
|
||||
progress_bar_len += network_size - len(miners)
|
||||
asyncio.create_task(update_prog_bar(progress_bar_len))
|
||||
await update_ui_with_data("status", "Getting Data")
|
||||
logging.debug("Getting data on miners.")
|
||||
@@ -334,14 +351,22 @@ async def scan_and_get_data(network):
|
||||
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["model"], data_point["host"], str(data_point['TH/s']) + " TH/s ",
|
||||
data_point["IP"],
|
||||
data_point["model"],
|
||||
data_point["host"],
|
||||
str(data_point["TH/s"]) + " TH/s ",
|
||||
data_point["temp"],
|
||||
data_point['user'], str(data_point['wattage']) + " W"
|
||||
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))
|
||||
hashrate_list = [float(item[3].replace(" TH/s ", "")) for item in window["ip_table"].Values if not item[3] == '']
|
||||
hashrate_list = [
|
||||
float(item[3].replace(" TH/s ", ""))
|
||||
for item in window["ip_table"].Values
|
||||
if not item[3] == ""
|
||||
]
|
||||
total_hr = round(sum(hashrate_list), 2)
|
||||
await update_ui_with_data("hr_total", f"{total_hr} TH/s")
|
||||
await update_ui_with_data("status", "")
|
||||
@@ -350,7 +375,7 @@ async def scan_and_get_data(network):
|
||||
async def get_formatted_data(ip: ipaddress.ip_address):
|
||||
miner = await MinerFactory().get_miner(ip)
|
||||
logging.debug(f"Getting data for miner: {miner.ip}")
|
||||
warnings.filterwarnings('ignore')
|
||||
warnings.filterwarnings("ignore")
|
||||
miner_data = None
|
||||
host = await miner.get_hostname()
|
||||
try:
|
||||
@@ -365,81 +390,144 @@ async def get_formatted_data(ip: ipaddress.ip_address):
|
||||
user = "?"
|
||||
|
||||
try:
|
||||
miner_data = await miner.api.multicommand("summary", "devs", "temps", "tunerstatus", "pools", "stats")
|
||||
miner_data = await miner.api.multicommand(
|
||||
"summary", "devs", "temps", "tunerstatus", "pools", "stats"
|
||||
)
|
||||
except APIError:
|
||||
try:
|
||||
# no devs command, it will fail in this case
|
||||
miner_data = await miner.api.multicommand("summary", "temps", "tunerstatus", "pools", "stats")
|
||||
miner_data = await miner.api.multicommand(
|
||||
"summary", "temps", "tunerstatus", "pools", "stats"
|
||||
)
|
||||
except APIError as e:
|
||||
logging.warning(f"{str(ip)}: {e}")
|
||||
return {'TH/s': 0, 'IP': str(miner.ip), 'model': 'Unknown', 'temp': 0, 'host': 'Unknown', 'user': 'Unknown',
|
||||
'wattage': 0}
|
||||
return {
|
||||
"TH/s": 0,
|
||||
"IP": str(miner.ip),
|
||||
"model": "Unknown",
|
||||
"temp": 0,
|
||||
"host": "Unknown",
|
||||
"user": "Unknown",
|
||||
"wattage": 0,
|
||||
}
|
||||
if miner_data:
|
||||
logging.info(f"Received miner data for miner: {miner.ip}")
|
||||
# get all data from summary
|
||||
if "summary" in miner_data.keys():
|
||||
if not miner_data["summary"][0].get("SUMMARY") == [] and "SUMMARY" in miner_data["summary"][0].keys():
|
||||
if (
|
||||
not miner_data["summary"][0].get("SUMMARY") == []
|
||||
and "SUMMARY" in miner_data["summary"][0].keys()
|
||||
):
|
||||
# temperature data, this is the idea spot to get this
|
||||
if "Temperature" in miner_data['summary'][0]['SUMMARY'][0].keys():
|
||||
if not round(miner_data['summary'][0]['SUMMARY'][0]["Temperature"]) == 0:
|
||||
temps = miner_data['summary'][0]['SUMMARY'][0]["Temperature"]
|
||||
if "Temperature" in miner_data["summary"][0]["SUMMARY"][0].keys():
|
||||
if (
|
||||
not round(miner_data["summary"][0]["SUMMARY"][0]["Temperature"])
|
||||
== 0
|
||||
):
|
||||
temps = miner_data["summary"][0]["SUMMARY"][0]["Temperature"]
|
||||
# hashrate data
|
||||
if 'MHS av' in miner_data['summary'][0]['SUMMARY'][0].keys():
|
||||
th5s = format(round(await safe_parse_api_data(miner_data, 'summary', 0, 'SUMMARY', 0, 'MHS av') / 1000000, 2), ".2f").rjust(6, " ")
|
||||
elif 'GHS av' in miner_data['summary'][0]['SUMMARY'][0].keys():
|
||||
if not miner_data['summary'][0]['SUMMARY'][0]['GHS av'] == "":
|
||||
th5s = format(round(
|
||||
float(await safe_parse_api_data(miner_data, 'summary', 0, 'SUMMARY', 0, 'GHS av')) / 1000,
|
||||
2), ".2f").rjust(6, " ")
|
||||
if "MHS av" in miner_data["summary"][0]["SUMMARY"][0].keys():
|
||||
th5s = format(
|
||||
round(
|
||||
await safe_parse_api_data(
|
||||
miner_data, "summary", 0, "SUMMARY", 0, "MHS av"
|
||||
)
|
||||
/ 1000000,
|
||||
2,
|
||||
),
|
||||
".2f",
|
||||
).rjust(6, " ")
|
||||
elif "GHS av" in miner_data["summary"][0]["SUMMARY"][0].keys():
|
||||
if not miner_data["summary"][0]["SUMMARY"][0]["GHS av"] == "":
|
||||
th5s = format(
|
||||
round(
|
||||
float(
|
||||
await safe_parse_api_data(
|
||||
miner_data, "summary", 0, "SUMMARY", 0, "GHS av"
|
||||
)
|
||||
)
|
||||
/ 1000,
|
||||
2,
|
||||
),
|
||||
".2f",
|
||||
).rjust(6, " ")
|
||||
|
||||
# alternate temperature data, for BraiinsOS
|
||||
if "temps" in miner_data.keys():
|
||||
if not miner_data["temps"][0].get('TEMPS') == []:
|
||||
if "Chip" in miner_data["temps"][0]['TEMPS'][0].keys():
|
||||
for board in miner_data["temps"][0]['TEMPS']:
|
||||
if not miner_data["temps"][0].get("TEMPS") == []:
|
||||
if "Chip" in miner_data["temps"][0]["TEMPS"][0].keys():
|
||||
for board in miner_data["temps"][0]["TEMPS"]:
|
||||
if board["Chip"] is not None and not board["Chip"] == 0.0:
|
||||
temps = board["Chip"]
|
||||
# alternate temperature data, for Whatsminers
|
||||
if "devs" in miner_data.keys():
|
||||
if not miner_data["devs"][0].get('DEVS') == []:
|
||||
if "Chip Temp Avg" in miner_data["devs"][0]['DEVS'][0].keys():
|
||||
for board in miner_data["devs"][0]['DEVS']:
|
||||
if board['Chip Temp Avg'] is not None and not board['Chip Temp Avg'] == 0.0:
|
||||
temps = board['Chip Temp Avg']
|
||||
if not miner_data["devs"][0].get("DEVS") == []:
|
||||
if "Chip Temp Avg" in miner_data["devs"][0]["DEVS"][0].keys():
|
||||
for board in miner_data["devs"][0]["DEVS"]:
|
||||
if (
|
||||
board["Chip Temp Avg"] is not None
|
||||
and not board["Chip Temp Avg"] == 0.0
|
||||
):
|
||||
temps = board["Chip Temp Avg"]
|
||||
# alternate temperature data
|
||||
if "stats" in miner_data.keys():
|
||||
if not miner_data["stats"][0]['STATS'] == []:
|
||||
if not miner_data["stats"][0]["STATS"] == []:
|
||||
for temp in ["temp2", "temp1", "temp3"]:
|
||||
if temp in miner_data["stats"][0]['STATS'][1].keys():
|
||||
if miner_data["stats"][0]['STATS'][1][temp] is not None and not miner_data["stats"][0]['STATS'][1][temp] == 0.0:
|
||||
temps = miner_data["stats"][0]['STATS'][1][temp]
|
||||
if temp in miner_data["stats"][0]["STATS"][1].keys():
|
||||
if (
|
||||
miner_data["stats"][0]["STATS"][1][temp] is not None
|
||||
and not miner_data["stats"][0]["STATS"][1][temp] == 0.0
|
||||
):
|
||||
temps = miner_data["stats"][0]["STATS"][1][temp]
|
||||
# alternate temperature data, for Avalonminers
|
||||
miner_data["stats"][0]['STATS'][0].keys()
|
||||
if any("MM ID" in string for string in miner_data["stats"][0]['STATS'][0].keys()):
|
||||
miner_data["stats"][0]["STATS"][0].keys()
|
||||
if any(
|
||||
"MM ID" in string
|
||||
for string in miner_data["stats"][0]["STATS"][0].keys()
|
||||
):
|
||||
temp_all = []
|
||||
for key in [string for string in miner_data["stats"][0]['STATS'][0].keys() if "MM ID" in string]:
|
||||
for value in [string for string in miner_data["stats"][0]['STATS'][0][key].split(" ") if
|
||||
"TMax" in string]:
|
||||
for key in [
|
||||
string
|
||||
for string in miner_data["stats"][0]["STATS"][0].keys()
|
||||
if "MM ID" in string
|
||||
]:
|
||||
for value in [
|
||||
string
|
||||
for string in miner_data["stats"][0]["STATS"][0][key].split(" ")
|
||||
if "TMax" in string
|
||||
]:
|
||||
temp_all.append(int(value.split("[")[1].replace("]", "")))
|
||||
temps = round(sum(temp_all) / len(temp_all))
|
||||
|
||||
# pool information
|
||||
if "pools" in miner_data.keys():
|
||||
if not miner_data['pools'][0].get('POOLS') == []:
|
||||
user = await safe_parse_api_data(miner_data, 'pools', 0, 'POOLS', 0, 'User')
|
||||
if not miner_data["pools"][0].get("POOLS") == []:
|
||||
user = await safe_parse_api_data(
|
||||
miner_data, "pools", 0, "POOLS", 0, "User"
|
||||
)
|
||||
else:
|
||||
print(miner_data['pools'][0])
|
||||
print(miner_data["pools"][0])
|
||||
user = "Blank"
|
||||
|
||||
# braiins tuner status / wattage
|
||||
if "tunerstatus" in miner_data.keys():
|
||||
wattage = await safe_parse_api_data(miner_data, "tunerstatus", 0, 'TUNERSTATUS', 0, "PowerLimit")
|
||||
wattage = await safe_parse_api_data(
|
||||
miner_data, "tunerstatus", 0, "TUNERSTATUS", 0, "PowerLimit"
|
||||
)
|
||||
elif "Power" in miner_data["summary"][0]["SUMMARY"][0].keys():
|
||||
wattage = await safe_parse_api_data(miner_data, "summary", 0, 'SUMMARY', 0, "Power")
|
||||
wattage = await safe_parse_api_data(
|
||||
miner_data, "summary", 0, "SUMMARY", 0, "Power"
|
||||
)
|
||||
|
||||
ret_data = {'TH/s': th5s, 'IP': str(miner.ip), 'model': model,
|
||||
'temp': round(temps), 'host': host, 'user': user,
|
||||
'wattage': wattage}
|
||||
ret_data = {
|
||||
"TH/s": th5s,
|
||||
"IP": str(miner.ip),
|
||||
"model": model,
|
||||
"temp": round(temps),
|
||||
"host": host,
|
||||
"user": user,
|
||||
"wattage": wattage,
|
||||
}
|
||||
|
||||
logging.debug(f"{ret_data}")
|
||||
|
||||
@@ -455,46 +543,37 @@ async def generate_config(username, workername, v2_allowed):
|
||||
return
|
||||
|
||||
if v2_allowed:
|
||||
url_1 = 'stratum2+tcp://v2.us-east.stratum.slushpool.com/u95GEReVMjK6k5YqiSFNqqTnKU4ypU2Wm8awa6tmbmDmk1bWt'
|
||||
url_2 = 'stratum2+tcp://v2.stratum.slushpool.com/u95GEReVMjK6k5YqiSFNqqTnKU4ypU2Wm8awa6tmbmDmk1bWt'
|
||||
url_3 = 'stratum+tcp://stratum.slushpool.com:3333'
|
||||
url_1 = "stratum2+tcp://v2.us-east.stratum.slushpool.com/u95GEReVMjK6k5YqiSFNqqTnKU4ypU2Wm8awa6tmbmDmk1bWt"
|
||||
url_2 = "stratum2+tcp://v2.stratum.slushpool.com/u95GEReVMjK6k5YqiSFNqqTnKU4ypU2Wm8awa6tmbmDmk1bWt"
|
||||
url_3 = "stratum+tcp://stratum.slushpool.com:3333"
|
||||
else:
|
||||
url_1 = 'stratum+tcp://ca.stratum.slushpool.com:3333'
|
||||
url_2 = 'stratum+tcp://us-east.stratum.slushpool.com:3333'
|
||||
url_3 = 'stratum+tcp://stratum.slushpool.com:3333'
|
||||
url_1 = "stratum+tcp://ca.stratum.slushpool.com:3333"
|
||||
url_2 = "stratum+tcp://us-east.stratum.slushpool.com:3333"
|
||||
url_3 = "stratum+tcp://stratum.slushpool.com:3333"
|
||||
|
||||
config = {
|
||||
'group': [{
|
||||
'name': 'group',
|
||||
'quota': 1,
|
||||
'pool': [{
|
||||
'url': url_1,
|
||||
'user': user,
|
||||
'password': '123'
|
||||
}, {
|
||||
'url': url_2,
|
||||
'user': user,
|
||||
'password': '123'
|
||||
}, {
|
||||
'url': url_3,
|
||||
'user': user,
|
||||
'password': '123'
|
||||
}]
|
||||
}],
|
||||
'format': {
|
||||
'version': '1.2+',
|
||||
'model': 'Antminer S9',
|
||||
'generator': 'upstream_config_util',
|
||||
'timestamp': int(time.time())
|
||||
"group": [
|
||||
{
|
||||
"name": "group",
|
||||
"quota": 1,
|
||||
"pool": [
|
||||
{"url": url_1, "user": user, "password": "123"},
|
||||
{"url": url_2, "user": user, "password": "123"},
|
||||
{"url": url_3, "user": user, "password": "123"},
|
||||
],
|
||||
}
|
||||
],
|
||||
"format": {
|
||||
"version": "1.2+",
|
||||
"model": "Antminer S9",
|
||||
"generator": "upstream_config_util",
|
||||
"timestamp": int(time.time()),
|
||||
},
|
||||
'temp_control': {
|
||||
'target_temp': 80.0,
|
||||
'hot_temp': 90.0,
|
||||
'dangerous_temp': 120.0
|
||||
"temp_control": {
|
||||
"target_temp": 80.0,
|
||||
"hot_temp": 90.0,
|
||||
"dangerous_temp": 120.0,
|
||||
},
|
||||
'autotuning': {
|
||||
'enabled': True,
|
||||
'psu_power_limit': 900
|
||||
}
|
||||
"autotuning": {"enabled": True, "psu_power_limit": 900},
|
||||
}
|
||||
window['config'].update(await bos_config_convert(config))
|
||||
window["config"].update(await bos_config_convert(config))
|
||||
|
||||
@@ -4,7 +4,7 @@ from API import APIError
|
||||
# noinspection PyPep8
|
||||
async def safe_parse_api_data(data: dict or list, *path: str or int, idx: int = 0):
|
||||
path = [*path]
|
||||
if len(path) == idx+1:
|
||||
if len(path) == idx + 1:
|
||||
if isinstance(path[idx], str):
|
||||
if isinstance(data, dict):
|
||||
if path[idx] in data.keys():
|
||||
@@ -17,34 +17,50 @@ async def safe_parse_api_data(data: dict or list, *path: str or int, idx: int =
|
||||
if isinstance(path[idx], str):
|
||||
if isinstance(data, dict):
|
||||
if path[idx] in data.keys():
|
||||
parsed_data = await safe_parse_api_data(data[path[idx]], idx=idx+1, *path)
|
||||
parsed_data = await safe_parse_api_data(
|
||||
data[path[idx]], idx=idx + 1, *path
|
||||
)
|
||||
# has to be == None, or else it fails on 0.0 hashrates
|
||||
# noinspection PyPep8
|
||||
if parsed_data == None:
|
||||
raise APIError(f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}")
|
||||
raise APIError(
|
||||
f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}"
|
||||
)
|
||||
return parsed_data
|
||||
else:
|
||||
if idx == 0:
|
||||
raise APIError(f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}")
|
||||
raise APIError(
|
||||
f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}"
|
||||
)
|
||||
return False
|
||||
else:
|
||||
if idx == 0:
|
||||
raise APIError(f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}")
|
||||
raise APIError(
|
||||
f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}"
|
||||
)
|
||||
return False
|
||||
elif isinstance(path[idx], int):
|
||||
if isinstance(data, list):
|
||||
if len(data) > path[idx]:
|
||||
parsed_data = await safe_parse_api_data(data[path[idx]], idx=idx+1, *path)
|
||||
parsed_data = await safe_parse_api_data(
|
||||
data[path[idx]], idx=idx + 1, *path
|
||||
)
|
||||
# has to be == None, or else it fails on 0.0 hashrates
|
||||
# noinspection PyPep8
|
||||
if parsed_data == None:
|
||||
raise APIError(f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}")
|
||||
raise APIError(
|
||||
f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}"
|
||||
)
|
||||
return parsed_data
|
||||
else:
|
||||
if idx == 0:
|
||||
raise APIError(f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}")
|
||||
raise APIError(
|
||||
f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}"
|
||||
)
|
||||
return False
|
||||
else:
|
||||
if idx == 0:
|
||||
raise APIError(f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}")
|
||||
raise APIError(
|
||||
f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}"
|
||||
)
|
||||
return False
|
||||
|
||||
@@ -8,9 +8,7 @@ import pyperclip
|
||||
|
||||
def table_select_all():
|
||||
window["ip_table"].update(
|
||||
select_rows=(
|
||||
[row for row in range(len(window["ip_table"].Values))]
|
||||
)
|
||||
select_rows=([row for row in range(len(window["ip_table"].Values))])
|
||||
)
|
||||
|
||||
|
||||
@@ -40,7 +38,6 @@ def copy_from_ssh_table(table):
|
||||
pyperclip.copy(copy_string)
|
||||
|
||||
|
||||
|
||||
async def update_ui_with_data(key, message, append=False):
|
||||
if append:
|
||||
message = window[key].get_text() + message
|
||||
@@ -49,7 +46,7 @@ async def update_ui_with_data(key, message, append=False):
|
||||
|
||||
async def update_prog_bar(amount):
|
||||
window["progress"].Update(amount)
|
||||
percent_done = 100 * (amount / window['progress'].maxlen)
|
||||
percent_done = 100 * (amount / window["progress"].maxlen)
|
||||
window["progress_percent"].Update(f"{round(percent_done, 2)} %")
|
||||
if percent_done == 100:
|
||||
window["progress_percent"].Update("")
|
||||
@@ -65,7 +62,7 @@ async def sort_data(index: int or str):
|
||||
if window["scan"].Disabled:
|
||||
return
|
||||
await update_ui_with_data("status", "Sorting Data")
|
||||
data_list = window['ip_table'].Values
|
||||
data_list = window["ip_table"].Values
|
||||
table = window["ip_table"].Widget
|
||||
all_data = []
|
||||
for idx, item in enumerate(data_list):
|
||||
@@ -73,22 +70,42 @@ async def sort_data(index: int or str):
|
||||
|
||||
# wattage
|
||||
if re.match("[0-9]* W", str(all_data[0]["data"][index])):
|
||||
new_list = sorted(all_data, key=lambda x: int(x["data"][index].replace(" W", "")))
|
||||
new_list = sorted(
|
||||
all_data, key=lambda x: int(x["data"][index].replace(" W", ""))
|
||||
)
|
||||
if all_data == new_list:
|
||||
new_list = sorted(all_data, reverse=True, key=lambda x: int(x["data"][index].replace(" W", "")))
|
||||
new_list = sorted(
|
||||
all_data,
|
||||
reverse=True,
|
||||
key=lambda x: int(x["data"][index].replace(" W", "")),
|
||||
)
|
||||
|
||||
# hashrate
|
||||
elif re.match("[0-9]*\.?[0-9]* TH\/s", str(all_data[0]["data"][index])):
|
||||
new_list = sorted(all_data, key=lambda x: float(x["data"][index].replace(" TH/s", "")))
|
||||
new_list = sorted(
|
||||
all_data, key=lambda x: float(x["data"][index].replace(" TH/s", ""))
|
||||
)
|
||||
if all_data == new_list:
|
||||
new_list = sorted(all_data, reverse=True, key=lambda x: float(x["data"][index].replace(" TH/s", "")))
|
||||
new_list = sorted(
|
||||
all_data,
|
||||
reverse=True,
|
||||
key=lambda x: float(x["data"][index].replace(" TH/s", "")),
|
||||
)
|
||||
|
||||
# ip addresses
|
||||
elif re.match("^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",
|
||||
str(all_data[0]["data"][index])):
|
||||
new_list = sorted(all_data, key=lambda x: ipaddress.ip_address(x["data"][index]))
|
||||
elif re.match(
|
||||
"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",
|
||||
str(all_data[0]["data"][index]),
|
||||
):
|
||||
new_list = sorted(
|
||||
all_data, key=lambda x: ipaddress.ip_address(x["data"][index])
|
||||
)
|
||||
if all_data == new_list:
|
||||
new_list = sorted(all_data, reverse=True, key=lambda x: ipaddress.ip_address(x["data"][index]))
|
||||
new_list = sorted(
|
||||
all_data,
|
||||
reverse=True,
|
||||
key=lambda x: ipaddress.ip_address(x["data"][index]),
|
||||
)
|
||||
|
||||
# everything else, hostname, temp, and user
|
||||
else:
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -3,13 +3,36 @@ import sys
|
||||
import PySimpleGUI as sg
|
||||
import tkinter as tk
|
||||
|
||||
from tools.cfg_util.cfg_util_sg.layout import window, generate_config_layout, send_ssh_cmd_layout
|
||||
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, send_miners_ssh_commands
|
||||
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.layout import (
|
||||
window,
|
||||
generate_config_layout,
|
||||
send_ssh_cmd_layout,
|
||||
)
|
||||
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,
|
||||
send_miners_ssh_commands,
|
||||
)
|
||||
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.decorators import disable_buttons
|
||||
from tools.cfg_util.cfg_util_sg.func.ui import sort_data, copy_from_table, table_select_all, copy_from_ssh_table
|
||||
from tools.cfg_util.cfg_util_sg.func.ui import (
|
||||
sort_data,
|
||||
copy_from_table,
|
||||
table_select_all,
|
||||
copy_from_ssh_table,
|
||||
)
|
||||
|
||||
from network import MinerNetwork
|
||||
|
||||
@@ -27,62 +50,112 @@ async def ui():
|
||||
table.column(2, anchor=tk.W)
|
||||
while True:
|
||||
event, value = window.read(timeout=0)
|
||||
if event in (None, 'Close', sg.WIN_CLOSED):
|
||||
if event in (None, "Close", sg.WIN_CLOSED):
|
||||
sys.exit()
|
||||
if isinstance(event, tuple):
|
||||
if len(window["ip_table"].Values) > 0:
|
||||
if event[0] == 'ip_table':
|
||||
if event[0] == "ip_table":
|
||||
if event[2][0] == -1:
|
||||
await sort_data(event[2][1])
|
||||
if event == 'open_in_web':
|
||||
if event == "open_in_web":
|
||||
for row in value["ip_table"]:
|
||||
webbrowser.open("http://" + window["ip_table"].Values[row][0])
|
||||
if event == 'scan':
|
||||
if len(value['miner_network'].split("/")) > 1:
|
||||
network = value['miner_network'].split("/")
|
||||
if event == "scan":
|
||||
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'])
|
||||
miner_network = MinerNetwork(value["miner_network"])
|
||||
asyncio.create_task(scan_and_get_data(miner_network))
|
||||
if event == 'select_all_ips':
|
||||
if event == "select_all_ips":
|
||||
if len(value["ip_table"]) == len(window["ip_table"].Values):
|
||||
window["ip_table"].update(select_rows=())
|
||||
else:
|
||||
window["ip_table"].update(select_rows=([row for row in range(len(window["ip_table"].Values))]))
|
||||
if event == 'import_config':
|
||||
if 2 > len(value['ip_table']) > 0:
|
||||
asyncio.create_task(import_config(value['ip_table']))
|
||||
window["ip_table"].update(
|
||||
select_rows=([row for row in range(len(window["ip_table"].Values))])
|
||||
)
|
||||
if event == "import_config":
|
||||
if 2 > len(value["ip_table"]) > 0:
|
||||
asyncio.create_task(import_config(value["ip_table"]))
|
||||
if event == "restart_miner_backend":
|
||||
if len(window["ip_table"].Values) > 0:
|
||||
asyncio.create_task(restart_miners_backend([window['ip_table'].Values[item][0] for item in value['ip_table']]))
|
||||
asyncio.create_task(
|
||||
restart_miners_backend(
|
||||
[
|
||||
window["ip_table"].Values[item][0]
|
||||
for item in value["ip_table"]
|
||||
]
|
||||
)
|
||||
)
|
||||
if event == "reboot_miners":
|
||||
if len(window["ip_table"].Values) > 0:
|
||||
asyncio.create_task(reboot_miners([window['ip_table'].Values[item][0] for item in value['ip_table']]))
|
||||
asyncio.create_task(
|
||||
reboot_miners(
|
||||
[
|
||||
window["ip_table"].Values[item][0]
|
||||
for item in value["ip_table"]
|
||||
]
|
||||
)
|
||||
)
|
||||
if event == "send_miner_ssh_command_window":
|
||||
ips = [window['ip_table'].Values[item][0] for item in value['ip_table']]
|
||||
ips = [window["ip_table"].Values[item][0] for item in value["ip_table"]]
|
||||
if len(ips) == 0:
|
||||
ips = [item[0] for item in window["ip_table"].Values]
|
||||
if not len(ips) == 0:
|
||||
await generate_ssh_cmd_ui(ips)
|
||||
if event == 'light':
|
||||
if event == "light":
|
||||
if len(window["ip_table"].Values) > 0:
|
||||
asyncio.create_task(miner_light([window['ip_table'].Values[item][0] for item in value['ip_table']]))
|
||||
asyncio.create_task(
|
||||
miner_light(
|
||||
[
|
||||
window["ip_table"].Values[item][0]
|
||||
for item in value["ip_table"]
|
||||
]
|
||||
)
|
||||
)
|
||||
if event == "import_iplist":
|
||||
asyncio.create_task(import_iplist(value["file_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']]))
|
||||
asyncio.create_task(
|
||||
export_csv(
|
||||
value["file_iplist"],
|
||||
[window["ip_table"].Values[item] for item in value["ip_table"]],
|
||||
)
|
||||
)
|
||||
if event == "send_config":
|
||||
if len(window["ip_table"].Values) > 0:
|
||||
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":
|
||||
asyncio.create_task(import_config_file(value['file_config']))
|
||||
asyncio.create_task(import_config_file(value["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 == "refresh_data":
|
||||
if len(window["ip_table"].Values) > 0:
|
||||
asyncio.create_task(refresh_data([window["ip_table"].Values[item][0] for item in value["ip_table"]]))
|
||||
asyncio.create_task(
|
||||
refresh_data(
|
||||
[
|
||||
window["ip_table"].Values[item][0]
|
||||
for item in value["ip_table"]
|
||||
]
|
||||
)
|
||||
)
|
||||
if event == "generate_config":
|
||||
await generate_config_ui()
|
||||
if event == "__TIMEOUT__":
|
||||
@@ -90,23 +163,29 @@ async def ui():
|
||||
|
||||
|
||||
async def generate_config_ui():
|
||||
generate_config_window = sg.Window("Generate Config", generate_config_layout(), modal=True)
|
||||
generate_config_window = sg.Window(
|
||||
"Generate Config", generate_config_layout(), modal=True
|
||||
)
|
||||
while True:
|
||||
event, values = generate_config_window.read()
|
||||
if event in (None, 'Close', sg.WIN_CLOSED):
|
||||
if event in (None, "Close", sg.WIN_CLOSED):
|
||||
break
|
||||
if event == "generate_config_window_generate":
|
||||
if values['generate_config_window_username']:
|
||||
await generate_config(values['generate_config_window_username'],
|
||||
values['generate_config_window_workername'],
|
||||
values['generate_config_window_allow_v2'])
|
||||
if values["generate_config_window_username"]:
|
||||
await generate_config(
|
||||
values["generate_config_window_username"],
|
||||
values["generate_config_window_workername"],
|
||||
values["generate_config_window_allow_v2"],
|
||||
)
|
||||
generate_config_window.close()
|
||||
break
|
||||
|
||||
|
||||
@disable_buttons
|
||||
async def generate_ssh_cmd_ui(selected_miners: list):
|
||||
ssh_cmd_window = sg.Window("Send Command", send_ssh_cmd_layout(selected_miners), modal=True)
|
||||
ssh_cmd_window = sg.Window(
|
||||
"Send Command", send_ssh_cmd_layout(selected_miners), modal=True
|
||||
)
|
||||
ssh_cmd_window.read(timeout=0)
|
||||
table = ssh_cmd_window["ssh_cmd_table"].Widget
|
||||
table.bind("<Control-Key-c>", lambda x: copy_from_ssh_table(table))
|
||||
@@ -114,9 +193,13 @@ async def generate_ssh_cmd_ui(selected_miners: list):
|
||||
table.column(1, anchor=tk.W)
|
||||
while True:
|
||||
event, values = ssh_cmd_window.read(timeout=0)
|
||||
if event in (None, 'Close', sg.WIN_CLOSED):
|
||||
if event in (None, "Close", sg.WIN_CLOSED):
|
||||
break
|
||||
if event == "ssh_command_window_send_cmd":
|
||||
asyncio.create_task(send_miners_ssh_commands(selected_miners, values["ssh_command_window_cmd"], ssh_cmd_window))
|
||||
asyncio.create_task(
|
||||
send_miners_ssh_commands(
|
||||
selected_miners, values["ssh_command_window_cmd"], ssh_cmd_window
|
||||
)
|
||||
)
|
||||
if event == "__TIMEOUT__":
|
||||
await asyncio.sleep(0)
|
||||
|
||||
@@ -4,7 +4,7 @@ from API import APIError
|
||||
# noinspection PyPep8
|
||||
async def safe_parse_api_data(data: dict or list, *path: str or int, idx: int = 0):
|
||||
path = [*path]
|
||||
if len(path) == idx+1:
|
||||
if len(path) == idx + 1:
|
||||
if isinstance(path[idx], str):
|
||||
if isinstance(data, dict):
|
||||
if path[idx] in data.keys():
|
||||
@@ -17,34 +17,50 @@ async def safe_parse_api_data(data: dict or list, *path: str or int, idx: int =
|
||||
if isinstance(path[idx], str):
|
||||
if isinstance(data, dict):
|
||||
if path[idx] in data.keys():
|
||||
parsed_data = await safe_parse_api_data(data[path[idx]], idx=idx+1, *path)
|
||||
parsed_data = await safe_parse_api_data(
|
||||
data[path[idx]], idx=idx + 1, *path
|
||||
)
|
||||
# has to be == None, or else it fails on 0.0 hashrates
|
||||
# noinspection PyPep8
|
||||
if parsed_data == None:
|
||||
raise APIError(f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}")
|
||||
raise APIError(
|
||||
f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}"
|
||||
)
|
||||
return parsed_data
|
||||
else:
|
||||
if idx == 0:
|
||||
raise APIError(f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}")
|
||||
raise APIError(
|
||||
f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}"
|
||||
)
|
||||
return False
|
||||
else:
|
||||
if idx == 0:
|
||||
raise APIError(f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}")
|
||||
raise APIError(
|
||||
f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}"
|
||||
)
|
||||
return False
|
||||
elif isinstance(path[idx], int):
|
||||
if isinstance(data, list):
|
||||
if len(data) > path[idx]:
|
||||
parsed_data = await safe_parse_api_data(data[path[idx]], idx=idx+1, *path)
|
||||
parsed_data = await safe_parse_api_data(
|
||||
data[path[idx]], idx=idx + 1, *path
|
||||
)
|
||||
# has to be == None, or else it fails on 0.0 hashrates
|
||||
# noinspection PyPep8
|
||||
if parsed_data == None:
|
||||
raise APIError(f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}")
|
||||
raise APIError(
|
||||
f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}"
|
||||
)
|
||||
return parsed_data
|
||||
else:
|
||||
if idx == 0:
|
||||
raise APIError(f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}")
|
||||
raise APIError(
|
||||
f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}"
|
||||
)
|
||||
return False
|
||||
else:
|
||||
if idx == 0:
|
||||
raise APIError(f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}")
|
||||
raise APIError(
|
||||
f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}"
|
||||
)
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user