added get hostname to X19 miners

This commit is contained in:
UpstreamData
2022-05-31 17:05:05 -06:00
parent 844deec0d3
commit 4087874b4a
6 changed files with 120 additions and 48 deletions

View File

@@ -10,8 +10,18 @@ class BMMinerS19(BMMiner, S19):
super().__init__(ip)
self.ip = ip
async def get_hostname(self) -> str:
return "?"
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"
@@ -19,9 +29,10 @@ class BMMinerS19(BMMiner, S19):
data = json.dumps({"blink": "true"})
async with httpx.AsyncClient() as client:
data = await client.post(url, data=data, auth=auth)
data = data.json()
if data.get("code") == "B000":
return True
if data.status_code == 200:
data = data.json()
if data.get("code") == "B000":
return True
return False
async def fault_light_off(self) -> bool:
@@ -30,7 +41,8 @@ class BMMinerS19(BMMiner, S19):
data = json.dumps({"blink": "false"})
async with httpx.AsyncClient() as client:
data = await client.post(url, data=data, auth=auth)
data = data.json()
if data.get("code") == "B100":
return True
if data.status_code == 200:
data = data.json()
if data.get("code") == "B100":
return True
return False

View File

@@ -10,8 +10,18 @@ class BMMinerS19Pro(BMMiner, S19Pro):
super().__init__(ip)
self.ip = ip
async def get_hostname(self) -> str:
return "?"
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"
@@ -19,9 +29,10 @@ class BMMinerS19Pro(BMMiner, S19Pro):
data = json.dumps({"blink": "true"})
async with httpx.AsyncClient() as client:
data = await client.post(url, data=data, auth=auth)
data = data.json()
if data.get("code") == "B000":
return True
if data.status_code == 200:
data = data.json()
if data.get("code") == "B000":
return True
return False
async def fault_light_off(self) -> bool:
@@ -30,7 +41,8 @@ class BMMinerS19Pro(BMMiner, S19Pro):
data = json.dumps({"blink": "false"})
async with httpx.AsyncClient() as client:
data = await client.post(url, data=data, auth=auth)
data = data.json()
if data.get("code") == "B100":
return True
if data.status_code == 200:
data = data.json()
if data.get("code") == "B100":
return True
return False

View File

@@ -10,8 +10,18 @@ class BMMinerS19a(BMMiner, S19a):
super().__init__(ip)
self.ip = ip
async def get_hostname(self) -> str:
return "?"
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"
@@ -19,9 +29,10 @@ class BMMinerS19a(BMMiner, S19a):
data = json.dumps({"blink": "true"})
async with httpx.AsyncClient() as client:
data = await client.post(url, data=data, auth=auth)
data = data.json()
if data.get("code") == "B000":
return True
if data.status_code == 200:
data = data.json()
if data.get("code") == "B000":
return True
return False
async def fault_light_off(self) -> bool:
@@ -30,7 +41,8 @@ class BMMinerS19a(BMMiner, S19a):
data = json.dumps({"blink": "false"})
async with httpx.AsyncClient() as client:
data = await client.post(url, data=data, auth=auth)
data = data.json()
if data.get("code") == "B100":
return True
if data.status_code == 200:
data = data.json()
if data.get("code") == "B100":
return True
return False

View File

@@ -10,8 +10,18 @@ class BMMinerS19j(BMMiner, S19j):
super().__init__(ip)
self.ip = ip
async def get_hostname(self) -> str:
return "?"
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"
@@ -19,9 +29,10 @@ class BMMinerS19j(BMMiner, S19j):
data = json.dumps({"blink": "true"})
async with httpx.AsyncClient() as client:
data = await client.post(url, data=data, auth=auth)
data = data.json()
if data.get("code") == "B000":
return True
if data.status_code == 200:
data = data.json()
if data.get("code") == "B000":
return True
return False
async def fault_light_off(self) -> bool:
@@ -30,7 +41,8 @@ class BMMinerS19j(BMMiner, S19j):
data = json.dumps({"blink": "false"})
async with httpx.AsyncClient() as client:
data = await client.post(url, data=data, auth=auth)
data = data.json()
if data.get("code") == "B100":
return True
if data.status_code == 200:
data = data.json()
if data.get("code") == "B100":
return True
return False

View File

@@ -10,8 +10,18 @@ class BMMinerS19jPro(BMMiner, S19jPro):
super().__init__(ip)
self.ip = ip
async def get_hostname(self) -> str:
return "?"
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"
@@ -19,9 +29,10 @@ class BMMinerS19jPro(BMMiner, S19jPro):
data = json.dumps({"blink": "true"})
async with httpx.AsyncClient() as client:
data = await client.post(url, data=data, auth=auth)
data = data.json()
if data.get("code") == "B000":
return True
if data.status_code == 200:
data = data.json()
if data.get("code") == "B000":
return True
return False
async def fault_light_off(self) -> bool:
@@ -30,7 +41,8 @@ class BMMinerS19jPro(BMMiner, S19jPro):
data = json.dumps({"blink": "false"})
async with httpx.AsyncClient() as client:
data = await client.post(url, data=data, auth=auth)
data = data.json()
if data.get("code") == "B100":
return True
if data.status_code == 200:
data = data.json()
if data.get("code") == "B100":
return True
return False

View File

@@ -10,8 +10,18 @@ class BMMinerT19(BMMiner, T19):
super().__init__(ip)
self.ip = ip
async def get_hostname(self) -> str:
return "?"
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"
@@ -19,9 +29,10 @@ class BMMinerT19(BMMiner, T19):
data = json.dumps({"blink": "true"})
async with httpx.AsyncClient() as client:
data = await client.post(url, data=data, auth=auth)
data = data.json()
if data.get("code") == "B000":
return True
if data.status_code == 200:
data = data.json()
if data.get("code") == "B000":
return True
return False
async def fault_light_off(self) -> bool:
@@ -30,7 +41,8 @@ class BMMinerT19(BMMiner, T19):
data = json.dumps({"blink": "false"})
async with httpx.AsyncClient() as client:
data = await client.post(url, data=data, auth=auth)
data = data.json()
if data.get("code") == "B100":
return True
if data.status_code == 200:
data = data.json()
if data.get("code") == "B100":
return True
return False