added configuration for X19 miners
This commit is contained in:
@@ -130,8 +130,8 @@ class MinerConfig:
|
|||||||
if key == "bitmain-fan-ctrl":
|
if key == "bitmain-fan-ctrl":
|
||||||
if data[key]:
|
if data[key]:
|
||||||
self.temp_mode = "manual"
|
self.temp_mode = "manual"
|
||||||
elif key == "bitmain-fan-pwm":
|
if data.get("bitmain-fan-pwm"):
|
||||||
self.fan_speed = data[key]
|
self.fan_speed = int(data["bitmain-fan-pwm"])
|
||||||
elif key == "fan_control":
|
elif key == "fan_control":
|
||||||
for _key in data[key].keys():
|
for _key in data[key].keys():
|
||||||
if _key == "min_fans":
|
if _key == "min_fans":
|
||||||
@@ -203,7 +203,7 @@ class MinerConfig:
|
|||||||
cfg["bitmain-fan-ctrl"] = True
|
cfg["bitmain-fan-ctrl"] = True
|
||||||
|
|
||||||
if self.fan_speed:
|
if self.fan_speed:
|
||||||
cfg["bitmain-fan-ctrl"] = self.fan_speed
|
cfg["bitmain-fan-ctrl"] = str(self.fan_speed)
|
||||||
|
|
||||||
return json.dumps(cfg)
|
return json.dumps(cfg)
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class BaseMiner:
|
|||||||
self.nominal_chips = 1
|
self.nominal_chips = 1
|
||||||
self.version = None
|
self.version = None
|
||||||
self.fan_count = 2
|
self.fan_count = 2
|
||||||
|
self.config = None
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"{'' if not self.api_type else self.api_type} {'' if not self.model else self.model}: {str(self.ip)}"
|
return f"{'' if not self.api_type else self.api_type} {'' if not self.model else self.model}: {str(self.ip)}"
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
from miners._backends import BMMiner # noqa - Ignore access to _module
|
from miners._backends import BMMiner # noqa - Ignore access to _module
|
||||||
from miners._types import S19 # noqa - Ignore access to _module
|
from miners._types import S19 # noqa - Ignore access to _module
|
||||||
|
|
||||||
|
from config.miner_config import MinerConfig
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
import json
|
import json
|
||||||
|
import asyncio
|
||||||
|
|
||||||
# TODO add config
|
|
||||||
|
|
||||||
|
|
||||||
class BMMinerS19(BMMiner, S19):
|
class BMMinerS19(BMMiner, S19):
|
||||||
@@ -13,6 +13,36 @@ class BMMinerS19(BMMiner, S19):
|
|||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
|
|
||||||
|
async def get_config(self) -> MinerConfig:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/get_miner_conf.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
data = await client.get(url, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
self.config = MinerConfig().from_raw(data)
|
||||||
|
return self.config
|
||||||
|
|
||||||
|
async def send_config(self, yaml_config, ip_user: bool = False) -> None:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/set_miner_conf.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
if ip_user:
|
||||||
|
suffix = str(self.ip).split(".")[-1]
|
||||||
|
conf = MinerConfig().from_yaml(yaml_config).as_x19(user_suffix=suffix)
|
||||||
|
else:
|
||||||
|
conf = MinerConfig().from_yaml(yaml_config).as_x19()
|
||||||
|
|
||||||
|
try:
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
await client.post(url, data=conf, auth=auth)
|
||||||
|
except httpx.ReadTimeout:
|
||||||
|
pass
|
||||||
|
for i in range(7):
|
||||||
|
data = await self.get_config()
|
||||||
|
if data.as_x19() == conf:
|
||||||
|
break
|
||||||
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
async def get_hostname(self) -> str or None:
|
async def get_hostname(self) -> str or None:
|
||||||
hostname = None
|
hostname = None
|
||||||
url = f"http://{self.ip}/cgi-bin/get_system_info.cgi"
|
url = f"http://{self.ip}/cgi-bin/get_system_info.cgi"
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
from miners._backends import BMMiner # noqa - Ignore access to _module
|
from miners._backends import BMMiner # noqa - Ignore access to _module
|
||||||
from miners._types import S19Pro # noqa - Ignore access to _module
|
from miners._types import S19Pro # noqa - Ignore access to _module
|
||||||
|
|
||||||
|
from config.miner_config import MinerConfig
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
import json
|
import json
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
|
||||||
class BMMinerS19Pro(BMMiner, S19Pro):
|
class BMMinerS19Pro(BMMiner, S19Pro):
|
||||||
@@ -10,6 +13,36 @@ class BMMinerS19Pro(BMMiner, S19Pro):
|
|||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
|
|
||||||
|
async def get_config(self) -> MinerConfig:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/get_miner_conf.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
data = await client.get(url, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
self.config = MinerConfig().from_raw(data)
|
||||||
|
return self.config
|
||||||
|
|
||||||
|
async def send_config(self, yaml_config, ip_user: bool = False) -> None:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/set_miner_conf.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
if ip_user:
|
||||||
|
suffix = str(self.ip).split(".")[-1]
|
||||||
|
conf = MinerConfig().from_yaml(yaml_config).as_x19(user_suffix=suffix)
|
||||||
|
else:
|
||||||
|
conf = MinerConfig().from_yaml(yaml_config).as_x19()
|
||||||
|
|
||||||
|
try:
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
await client.post(url, data=conf, auth=auth)
|
||||||
|
except httpx.ReadTimeout:
|
||||||
|
pass
|
||||||
|
for i in range(7):
|
||||||
|
data = await self.get_config()
|
||||||
|
if data.as_x19() == conf:
|
||||||
|
break
|
||||||
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
async def get_hostname(self) -> str or None:
|
async def get_hostname(self) -> str or None:
|
||||||
hostname = None
|
hostname = None
|
||||||
url = f"http://{self.ip}/cgi-bin/get_system_info.cgi"
|
url = f"http://{self.ip}/cgi-bin/get_system_info.cgi"
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
from miners._backends import BMMiner # noqa - Ignore access to _module
|
from miners._backends import BMMiner # noqa - Ignore access to _module
|
||||||
from miners._types import S19a # noqa - Ignore access to _module
|
from miners._types import S19a # noqa - Ignore access to _module
|
||||||
|
|
||||||
|
from config.miner_config import MinerConfig
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
import json
|
import json
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
|
||||||
class BMMinerS19a(BMMiner, S19a):
|
class BMMinerS19a(BMMiner, S19a):
|
||||||
@@ -10,6 +13,36 @@ class BMMinerS19a(BMMiner, S19a):
|
|||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
|
|
||||||
|
async def get_config(self) -> MinerConfig:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/get_miner_conf.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
data = await client.get(url, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
self.config = MinerConfig().from_raw(data)
|
||||||
|
return self.config
|
||||||
|
|
||||||
|
async def send_config(self, yaml_config, ip_user: bool = False) -> None:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/set_miner_conf.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
if ip_user:
|
||||||
|
suffix = str(self.ip).split(".")[-1]
|
||||||
|
conf = MinerConfig().from_yaml(yaml_config).as_x19(user_suffix=suffix)
|
||||||
|
else:
|
||||||
|
conf = MinerConfig().from_yaml(yaml_config).as_x19()
|
||||||
|
|
||||||
|
try:
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
await client.post(url, data=conf, auth=auth)
|
||||||
|
except httpx.ReadTimeout:
|
||||||
|
pass
|
||||||
|
for i in range(7):
|
||||||
|
data = await self.get_config()
|
||||||
|
if data.as_x19() == conf:
|
||||||
|
break
|
||||||
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
async def get_hostname(self) -> str or None:
|
async def get_hostname(self) -> str or None:
|
||||||
hostname = None
|
hostname = None
|
||||||
url = f"http://{self.ip}/cgi-bin/get_system_info.cgi"
|
url = f"http://{self.ip}/cgi-bin/get_system_info.cgi"
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
from miners._backends import BMMiner # noqa - Ignore access to _module
|
from miners._backends import BMMiner # noqa - Ignore access to _module
|
||||||
from miners._types import S19j # noqa - Ignore access to _module
|
from miners._types import S19j # noqa - Ignore access to _module
|
||||||
|
|
||||||
|
from config.miner_config import MinerConfig
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
import json
|
import json
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
|
||||||
class BMMinerS19j(BMMiner, S19j):
|
class BMMinerS19j(BMMiner, S19j):
|
||||||
@@ -10,6 +13,36 @@ class BMMinerS19j(BMMiner, S19j):
|
|||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
|
|
||||||
|
async def get_config(self) -> MinerConfig:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/get_miner_conf.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
data = await client.get(url, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
self.config = MinerConfig().from_raw(data)
|
||||||
|
return self.config
|
||||||
|
|
||||||
|
async def send_config(self, yaml_config, ip_user: bool = False) -> None:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/set_miner_conf.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
if ip_user:
|
||||||
|
suffix = str(self.ip).split(".")[-1]
|
||||||
|
conf = MinerConfig().from_yaml(yaml_config).as_x19(user_suffix=suffix)
|
||||||
|
else:
|
||||||
|
conf = MinerConfig().from_yaml(yaml_config).as_x19()
|
||||||
|
|
||||||
|
try:
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
await client.post(url, data=conf, auth=auth)
|
||||||
|
except httpx.ReadTimeout:
|
||||||
|
pass
|
||||||
|
for i in range(7):
|
||||||
|
data = await self.get_config()
|
||||||
|
if data.as_x19() == conf:
|
||||||
|
break
|
||||||
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
async def get_hostname(self) -> str or None:
|
async def get_hostname(self) -> str or None:
|
||||||
hostname = None
|
hostname = None
|
||||||
url = f"http://{self.ip}/cgi-bin/get_system_info.cgi"
|
url = f"http://{self.ip}/cgi-bin/get_system_info.cgi"
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
from miners._backends import BMMiner # noqa - Ignore access to _module
|
from miners._backends import BMMiner # noqa - Ignore access to _module
|
||||||
from miners._types import S19jPro # noqa - Ignore access to _module
|
from miners._types import S19jPro # noqa - Ignore access to _module
|
||||||
|
|
||||||
|
from config.miner_config import MinerConfig
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
import json
|
import json
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
|
||||||
class BMMinerS19jPro(BMMiner, S19jPro):
|
class BMMinerS19jPro(BMMiner, S19jPro):
|
||||||
@@ -10,6 +13,36 @@ class BMMinerS19jPro(BMMiner, S19jPro):
|
|||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
|
|
||||||
|
async def get_config(self) -> MinerConfig:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/get_miner_conf.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
data = await client.get(url, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
self.config = MinerConfig().from_raw(data)
|
||||||
|
return self.config
|
||||||
|
|
||||||
|
async def send_config(self, yaml_config, ip_user: bool = False) -> None:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/set_miner_conf.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
if ip_user:
|
||||||
|
suffix = str(self.ip).split(".")[-1]
|
||||||
|
conf = MinerConfig().from_yaml(yaml_config).as_x19(user_suffix=suffix)
|
||||||
|
else:
|
||||||
|
conf = MinerConfig().from_yaml(yaml_config).as_x19()
|
||||||
|
|
||||||
|
try:
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
await client.post(url, data=conf, auth=auth)
|
||||||
|
except httpx.ReadTimeout:
|
||||||
|
pass
|
||||||
|
for i in range(7):
|
||||||
|
data = await self.get_config()
|
||||||
|
if data.as_x19() == conf:
|
||||||
|
break
|
||||||
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
async def get_hostname(self) -> str or None:
|
async def get_hostname(self) -> str or None:
|
||||||
hostname = None
|
hostname = None
|
||||||
url = f"http://{self.ip}/cgi-bin/get_system_info.cgi"
|
url = f"http://{self.ip}/cgi-bin/get_system_info.cgi"
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
from miners._backends import BMMiner # noqa - Ignore access to _module
|
from miners._backends import BMMiner # noqa - Ignore access to _module
|
||||||
from miners._types import T19 # noqa - Ignore access to _module
|
from miners._types import T19 # noqa - Ignore access to _module
|
||||||
|
|
||||||
|
from config.miner_config import MinerConfig
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
import json
|
import json
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
|
||||||
class BMMinerT19(BMMiner, T19):
|
class BMMinerT19(BMMiner, T19):
|
||||||
@@ -10,6 +13,36 @@ class BMMinerT19(BMMiner, T19):
|
|||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
|
|
||||||
|
async def get_config(self) -> MinerConfig:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/get_miner_conf.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
data = await client.get(url, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
self.config = MinerConfig().from_raw(data)
|
||||||
|
return self.config
|
||||||
|
|
||||||
|
async def send_config(self, yaml_config, ip_user: bool = False) -> None:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/set_miner_conf.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
if ip_user:
|
||||||
|
suffix = str(self.ip).split(".")[-1]
|
||||||
|
conf = MinerConfig().from_yaml(yaml_config).as_x19(user_suffix=suffix)
|
||||||
|
else:
|
||||||
|
conf = MinerConfig().from_yaml(yaml_config).as_x19()
|
||||||
|
|
||||||
|
try:
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
await client.post(url, data=conf, auth=auth)
|
||||||
|
except httpx.ReadTimeout:
|
||||||
|
pass
|
||||||
|
for i in range(7):
|
||||||
|
data = await self.get_config()
|
||||||
|
if data.as_x19() == conf:
|
||||||
|
break
|
||||||
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
async def get_hostname(self) -> str or None:
|
async def get_hostname(self) -> str or None:
|
||||||
hostname = None
|
hostname = None
|
||||||
url = f"http://{self.ip}/cgi-bin/get_system_info.cgi"
|
url = f"http://{self.ip}/cgi-bin/get_system_info.cgi"
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ async def btn_import(table, selected):
|
|||||||
miner = await MinerFactory().get_miner(ip)
|
miner = await MinerFactory().get_miner(ip)
|
||||||
await miner.get_config()
|
await miner.get_config()
|
||||||
config = miner.config
|
config = miner.config
|
||||||
window["cfg_config_txt"].update(config.as_yaml())
|
if config:
|
||||||
|
window["cfg_config_txt"].update(config.as_yaml())
|
||||||
|
|
||||||
|
|
||||||
@disable_buttons("Configuring")
|
@disable_buttons("Configuring")
|
||||||
|
|||||||
Reference in New Issue
Block a user