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://pyasic.readthedocs.io/en/latest/)
|
||||

|
||||

|
||||
[](https://github.com/UpstreamData/pyasic/blob/master/LICENSE.txt)
|
||||
[](https://www.codefactor.io/repository/github/upstreamdata/pyasic)
|
||||
## Documentation
|
||||
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://pyasic.readthedocs.io/en/latest/)
|
||||

|
||||

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