update shields and improve typing and handling of fault light checks
This commit is contained in:
@@ -5,8 +5,8 @@
|
|||||||
[](https://pypi.org/project/pyasic/)
|
[](https://pypi.org/project/pyasic/)
|
||||||
[](https://pypi.org/project/pyasic/)
|
[](https://pypi.org/project/pyasic/)
|
||||||
[](https://pyasic.readthedocs.io/en/latest/)
|
[](https://pyasic.readthedocs.io/en/latest/)
|
||||||

|
[](https://github.com/UpstreamData/pyasic/blob/master/LICENSE.txt)
|
||||||

|
[](https://www.codefactor.io/repository/github/upstreamdata/pyasic)
|
||||||
## Documentation
|
## Documentation
|
||||||
Documentation is located on Read the Docs as [pyasic](https://pyasic.readthedocs.io/en/latest/)
|
Documentation is located on Read the Docs as [pyasic](https://pyasic.readthedocs.io/en/latest/)
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
[](https://pypi.org/project/pyasic/)
|
[](https://pypi.org/project/pyasic/)
|
||||||
[](https://pypi.org/project/pyasic/)
|
[](https://pypi.org/project/pyasic/)
|
||||||
[](https://pyasic.readthedocs.io/en/latest/)
|
[](https://pyasic.readthedocs.io/en/latest/)
|
||||||

|
[](https://github.com/UpstreamData/pyasic/blob/master/LICENSE.txt)
|
||||||

|
[](https://www.codefactor.io/repository/github/upstreamdata/pyasic)
|
||||||
|
|
||||||
## Intro
|
## Intro
|
||||||
Welcome to pyasic! Pyasic uses an asynchronous method of communicating with asic miners on your network, which makes it super fast.
|
Welcome to pyasic! Pyasic uses an asynchronous method of communicating with asic miners on your network, which makes it super fast.
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class BMMinerX17(BMMiner):
|
|||||||
hostname = data["hostname"]
|
hostname = data["hostname"]
|
||||||
return hostname
|
return hostname
|
||||||
|
|
||||||
async def get_mac(self):
|
async def get_mac(self) -> Union[str, None]:
|
||||||
mac = None
|
mac = None
|
||||||
url = f"http://{self.ip}/cgi-bin/get_system_info.cgi"
|
url = f"http://{self.ip}/cgi-bin/get_system_info.cgi"
|
||||||
auth = httpx.DigestAuth("root", "root")
|
auth = httpx.DigestAuth("root", "root")
|
||||||
@@ -62,6 +62,7 @@ class BMMinerX17(BMMiner):
|
|||||||
if data.status_code == 200:
|
if data.status_code == 200:
|
||||||
data = data.json()
|
data = data.json()
|
||||||
if data["isBlinking"]:
|
if data["isBlinking"]:
|
||||||
|
self.light = True
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -74,10 +75,13 @@ class BMMinerX17(BMMiner):
|
|||||||
if data.status_code == 200:
|
if data.status_code == 200:
|
||||||
data = data.json()
|
data = data.json()
|
||||||
if not data["isBlinking"]:
|
if not data["isBlinking"]:
|
||||||
|
self.light = False
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
async def check_light(self):
|
async def check_light(self) -> Union[bool, None]:
|
||||||
|
if self.light:
|
||||||
|
return self.light
|
||||||
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
auth = httpx.DigestAuth("root", "root")
|
auth = httpx.DigestAuth("root", "root")
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
@@ -85,8 +89,12 @@ class BMMinerX17(BMMiner):
|
|||||||
if data.status_code == 200:
|
if data.status_code == 200:
|
||||||
data = data.json()
|
data = data.json()
|
||||||
if data["isBlinking"]:
|
if data["isBlinking"]:
|
||||||
|
self.light = True
|
||||||
return True
|
return True
|
||||||
|
else:
|
||||||
|
self.light = False
|
||||||
return False
|
return False
|
||||||
|
return None
|
||||||
|
|
||||||
async def reboot(self) -> bool:
|
async def reboot(self) -> bool:
|
||||||
url = f"http://{self.ip}/cgi-bin/reboot.cgi"
|
url = f"http://{self.ip}/cgi-bin/reboot.cgi"
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ from pyasic.config import MinerConfig
|
|||||||
import httpx
|
import httpx
|
||||||
import json
|
import json
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
|
||||||
class BMMinerX19(BMMiner):
|
class BMMinerX19(BMMiner):
|
||||||
@@ -26,7 +27,7 @@ class BMMinerX19(BMMiner):
|
|||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
|
|
||||||
async def check_light(self) -> bool:
|
async def check_light(self) -> Union[bool, None]:
|
||||||
if self.light:
|
if self.light:
|
||||||
return self.light
|
return self.light
|
||||||
url = f"http://{self.ip}/cgi-bin/get_blink_status.cgi"
|
url = f"http://{self.ip}/cgi-bin/get_blink_status.cgi"
|
||||||
@@ -36,8 +37,9 @@ class BMMinerX19(BMMiner):
|
|||||||
if data.status_code == 200:
|
if data.status_code == 200:
|
||||||
data = data.json()
|
data = data.json()
|
||||||
light = data["blink"]
|
light = data["blink"]
|
||||||
|
self.light = light
|
||||||
return light
|
return light
|
||||||
return False
|
return None
|
||||||
|
|
||||||
async def get_config(self) -> MinerConfig:
|
async def get_config(self) -> MinerConfig:
|
||||||
url = f"http://{self.ip}/cgi-bin/get_miner_conf.cgi"
|
url = f"http://{self.ip}/cgi-bin/get_miner_conf.cgi"
|
||||||
@@ -69,7 +71,7 @@ class BMMinerX19(BMMiner):
|
|||||||
break
|
break
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
async def get_hostname(self) -> str or None:
|
async def get_hostname(self) -> Union[str, 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"
|
||||||
auth = httpx.DigestAuth("root", "root")
|
auth = httpx.DigestAuth("root", "root")
|
||||||
@@ -82,7 +84,7 @@ class BMMinerX19(BMMiner):
|
|||||||
hostname = data["hostname"]
|
hostname = data["hostname"]
|
||||||
return hostname
|
return hostname
|
||||||
|
|
||||||
async def get_mac(self):
|
async def get_mac(self) -> Union[str, None]:
|
||||||
mac = None
|
mac = None
|
||||||
url = f"http://{self.ip}/cgi-bin/get_system_info.cgi"
|
url = f"http://{self.ip}/cgi-bin/get_system_info.cgi"
|
||||||
auth = httpx.DigestAuth("root", "root")
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
|||||||
Reference in New Issue
Block a user