added fault light function for X17 BMMiner models
This commit is contained in:
@@ -1,8 +1,62 @@
|
|||||||
from miners._backends import BMMiner # noqa - Ignore access to _module
|
from miners._backends import BMMiner # noqa - Ignore access to _module
|
||||||
from miners._types import S17 # noqa - Ignore access to _module
|
from miners._types import S17 # noqa - Ignore access to _module
|
||||||
|
|
||||||
|
import httpx
|
||||||
|
|
||||||
|
|
||||||
class BMMinerS17(BMMiner, S17):
|
class BMMinerS17(BMMiner, S17):
|
||||||
def __init__(self, ip: str) -> None:
|
def __init__(self, ip: str) -> None:
|
||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
|
|
||||||
|
async def get_hostname(self) -> str or None:
|
||||||
|
hostname = None
|
||||||
|
url = f"http://{self.ip}/cgi-bin/get_system_info.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()
|
||||||
|
if len(data.keys()) > 0:
|
||||||
|
if "hostname" in data.keys():
|
||||||
|
hostname = data["hostname"]
|
||||||
|
return hostname
|
||||||
|
|
||||||
|
async def fault_light_on(self) -> bool:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
try:
|
||||||
|
await client.post(url, data={"action": "startBlink"}, auth=auth)
|
||||||
|
except httpx.ReadTimeout:
|
||||||
|
# Expected behaviour
|
||||||
|
pass
|
||||||
|
data = await client.post(url, data={"action": "onPageLoaded"}, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if data["isBlinking"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def fault_light_off(self) -> bool:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
await client.post(url, data={"action": "stopBlink"}, auth=auth)
|
||||||
|
data = await client.post(url, data={"action": "onPageLoaded"}, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if not data["isBlinking"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def check_light(self):
|
||||||
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
data = await client.post(url, data={"action": "onPageLoaded"}, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if data["isBlinking"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|||||||
@@ -1,8 +1,62 @@
|
|||||||
from miners._backends import BMMiner # noqa - Ignore access to _module
|
from miners._backends import BMMiner # noqa - Ignore access to _module
|
||||||
from miners._types import S17Plus # noqa - Ignore access to _module
|
from miners._types import S17Plus # noqa - Ignore access to _module
|
||||||
|
|
||||||
|
import httpx
|
||||||
|
|
||||||
|
|
||||||
class BMMinerS17Plus(BMMiner, S17Plus):
|
class BMMinerS17Plus(BMMiner, S17Plus):
|
||||||
def __init__(self, ip: str) -> None:
|
def __init__(self, ip: str) -> None:
|
||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
|
|
||||||
|
async def get_hostname(self) -> str or None:
|
||||||
|
hostname = None
|
||||||
|
url = f"http://{self.ip}/cgi-bin/get_system_info.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()
|
||||||
|
if len(data.keys()) > 0:
|
||||||
|
if "hostname" in data.keys():
|
||||||
|
hostname = data["hostname"]
|
||||||
|
return hostname
|
||||||
|
|
||||||
|
async def fault_light_on(self) -> bool:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
try:
|
||||||
|
await client.post(url, data={"action": "startBlink"}, auth=auth)
|
||||||
|
except httpx.ReadTimeout:
|
||||||
|
# Expected behaviour
|
||||||
|
pass
|
||||||
|
data = await client.post(url, data={"action": "onPageLoaded"}, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if data["isBlinking"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def fault_light_off(self) -> bool:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
await client.post(url, data={"action": "stopBlink"}, auth=auth)
|
||||||
|
data = await client.post(url, data={"action": "onPageLoaded"}, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if not data["isBlinking"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def check_light(self):
|
||||||
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
data = await client.post(url, data={"action": "onPageLoaded"}, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if data["isBlinking"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|||||||
@@ -1,8 +1,62 @@
|
|||||||
from miners._backends import BMMiner # noqa - Ignore access to _module
|
from miners._backends import BMMiner # noqa - Ignore access to _module
|
||||||
from miners._types import S17Pro # noqa - Ignore access to _module
|
from miners._types import S17Pro # noqa - Ignore access to _module
|
||||||
|
|
||||||
|
import httpx
|
||||||
|
|
||||||
|
|
||||||
class BMMinerS17Pro(BMMiner, S17Pro):
|
class BMMinerS17Pro(BMMiner, S17Pro):
|
||||||
def __init__(self, ip: str) -> None:
|
def __init__(self, ip: str) -> None:
|
||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
|
|
||||||
|
async def get_hostname(self) -> str or None:
|
||||||
|
hostname = None
|
||||||
|
url = f"http://{self.ip}/cgi-bin/get_system_info.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()
|
||||||
|
if len(data.keys()) > 0:
|
||||||
|
if "hostname" in data.keys():
|
||||||
|
hostname = data["hostname"]
|
||||||
|
return hostname
|
||||||
|
|
||||||
|
async def fault_light_on(self) -> bool:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
try:
|
||||||
|
await client.post(url, data={"action": "startBlink"}, auth=auth)
|
||||||
|
except httpx.ReadTimeout:
|
||||||
|
# Expected behaviour
|
||||||
|
pass
|
||||||
|
data = await client.post(url, data={"action": "onPageLoaded"}, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if data["isBlinking"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def fault_light_off(self) -> bool:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
await client.post(url, data={"action": "stopBlink"}, auth=auth)
|
||||||
|
data = await client.post(url, data={"action": "onPageLoaded"}, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if not data["isBlinking"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def check_light(self):
|
||||||
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
data = await client.post(url, data={"action": "onPageLoaded"}, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if data["isBlinking"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|||||||
@@ -1,8 +1,62 @@
|
|||||||
from miners._backends import BMMiner # noqa - Ignore access to _module
|
from miners._backends import BMMiner # noqa - Ignore access to _module
|
||||||
from miners._types import S17e # noqa - Ignore access to _module
|
from miners._types import S17e # noqa - Ignore access to _module
|
||||||
|
|
||||||
|
import httpx
|
||||||
|
|
||||||
|
|
||||||
class BMMinerS17e(BMMiner, S17e):
|
class BMMinerS17e(BMMiner, S17e):
|
||||||
def __init__(self, ip: str) -> None:
|
def __init__(self, ip: str) -> None:
|
||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
|
|
||||||
|
async def get_hostname(self) -> str or None:
|
||||||
|
hostname = None
|
||||||
|
url = f"http://{self.ip}/cgi-bin/get_system_info.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()
|
||||||
|
if len(data.keys()) > 0:
|
||||||
|
if "hostname" in data.keys():
|
||||||
|
hostname = data["hostname"]
|
||||||
|
return hostname
|
||||||
|
|
||||||
|
async def fault_light_on(self) -> bool:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
try:
|
||||||
|
await client.post(url, data={"action": "startBlink"}, auth=auth)
|
||||||
|
except httpx.ReadTimeout:
|
||||||
|
# Expected behaviour
|
||||||
|
pass
|
||||||
|
data = await client.post(url, data={"action": "onPageLoaded"}, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if data["isBlinking"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def fault_light_off(self) -> bool:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
await client.post(url, data={"action": "stopBlink"}, auth=auth)
|
||||||
|
data = await client.post(url, data={"action": "onPageLoaded"}, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if not data["isBlinking"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def check_light(self):
|
||||||
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
data = await client.post(url, data={"action": "onPageLoaded"}, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if data["isBlinking"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|||||||
@@ -1,8 +1,62 @@
|
|||||||
from miners._backends import BMMiner # noqa - Ignore access to _module
|
from miners._backends import BMMiner # noqa - Ignore access to _module
|
||||||
from miners._types import T17 # noqa - Ignore access to _module
|
from miners._types import T17 # noqa - Ignore access to _module
|
||||||
|
|
||||||
|
import httpx
|
||||||
|
|
||||||
|
|
||||||
class BMMinerT17(BMMiner, T17):
|
class BMMinerT17(BMMiner, T17):
|
||||||
def __init__(self, ip: str) -> None:
|
def __init__(self, ip: str) -> None:
|
||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
|
|
||||||
|
async def get_hostname(self) -> str or None:
|
||||||
|
hostname = None
|
||||||
|
url = f"http://{self.ip}/cgi-bin/get_system_info.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()
|
||||||
|
if len(data.keys()) > 0:
|
||||||
|
if "hostname" in data.keys():
|
||||||
|
hostname = data["hostname"]
|
||||||
|
return hostname
|
||||||
|
|
||||||
|
async def fault_light_on(self) -> bool:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
try:
|
||||||
|
await client.post(url, data={"action": "startBlink"}, auth=auth)
|
||||||
|
except httpx.ReadTimeout:
|
||||||
|
# Expected behaviour
|
||||||
|
pass
|
||||||
|
data = await client.post(url, data={"action": "onPageLoaded"}, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if data["isBlinking"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def fault_light_off(self) -> bool:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
await client.post(url, data={"action": "stopBlink"}, auth=auth)
|
||||||
|
data = await client.post(url, data={"action": "onPageLoaded"}, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if not data["isBlinking"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def check_light(self):
|
||||||
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
data = await client.post(url, data={"action": "onPageLoaded"}, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if data["isBlinking"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|||||||
@@ -1,8 +1,62 @@
|
|||||||
from miners._backends import BMMiner # noqa - Ignore access to _module
|
from miners._backends import BMMiner # noqa - Ignore access to _module
|
||||||
from miners._types import T17Plus # noqa - Ignore access to _module
|
from miners._types import T17Plus # noqa - Ignore access to _module
|
||||||
|
|
||||||
|
import httpx
|
||||||
|
|
||||||
|
|
||||||
class BMMinerT17Plus(BMMiner, T17Plus):
|
class BMMinerT17Plus(BMMiner, T17Plus):
|
||||||
def __init__(self, ip: str) -> None:
|
def __init__(self, ip: str) -> None:
|
||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
|
|
||||||
|
async def get_hostname(self) -> str or None:
|
||||||
|
hostname = None
|
||||||
|
url = f"http://{self.ip}/cgi-bin/get_system_info.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()
|
||||||
|
if len(data.keys()) > 0:
|
||||||
|
if "hostname" in data.keys():
|
||||||
|
hostname = data["hostname"]
|
||||||
|
return hostname
|
||||||
|
|
||||||
|
async def fault_light_on(self) -> bool:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
try:
|
||||||
|
await client.post(url, data={"action": "startBlink"}, auth=auth)
|
||||||
|
except httpx.ReadTimeout:
|
||||||
|
# Expected behaviour
|
||||||
|
pass
|
||||||
|
data = await client.post(url, data={"action": "onPageLoaded"}, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if data["isBlinking"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def fault_light_off(self) -> bool:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
await client.post(url, data={"action": "stopBlink"}, auth=auth)
|
||||||
|
data = await client.post(url, data={"action": "onPageLoaded"}, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if not data["isBlinking"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def check_light(self):
|
||||||
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
data = await client.post(url, data={"action": "onPageLoaded"}, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if data["isBlinking"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|||||||
@@ -1,8 +1,62 @@
|
|||||||
from miners._backends import BMMiner # noqa - Ignore access to _module
|
from miners._backends import BMMiner # noqa - Ignore access to _module
|
||||||
from miners._types import T17e # noqa - Ignore access to _module
|
from miners._types import T17e # noqa - Ignore access to _module
|
||||||
|
|
||||||
|
import httpx
|
||||||
|
|
||||||
|
|
||||||
class BMMinerT17e(BMMiner, T17e):
|
class BMMinerT17e(BMMiner, T17e):
|
||||||
def __init__(self, ip: str) -> None:
|
def __init__(self, ip: str) -> None:
|
||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
|
|
||||||
|
async def get_hostname(self) -> str or None:
|
||||||
|
hostname = None
|
||||||
|
url = f"http://{self.ip}/cgi-bin/get_system_info.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()
|
||||||
|
if len(data.keys()) > 0:
|
||||||
|
if "hostname" in data.keys():
|
||||||
|
hostname = data["hostname"]
|
||||||
|
return hostname
|
||||||
|
|
||||||
|
async def fault_light_on(self) -> bool:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
try:
|
||||||
|
await client.post(url, data={"action": "startBlink"}, auth=auth)
|
||||||
|
except httpx.ReadTimeout:
|
||||||
|
# Expected behaviour
|
||||||
|
pass
|
||||||
|
data = await client.post(url, data={"action": "onPageLoaded"}, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if data["isBlinking"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def fault_light_off(self) -> bool:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
await client.post(url, data={"action": "stopBlink"}, auth=auth)
|
||||||
|
data = await client.post(url, data={"action": "onPageLoaded"}, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if not data["isBlinking"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def check_light(self):
|
||||||
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
data = await client.post(url, data={"action": "onPageLoaded"}, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if data["isBlinking"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user