added get hostname to X19 miners
This commit is contained in:
@@ -10,8 +10,18 @@ class BMMinerS19(BMMiner, S19):
|
|||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
|
|
||||||
async def get_hostname(self) -> str:
|
async def get_hostname(self) -> str or None:
|
||||||
return "?"
|
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:
|
async def fault_light_on(self) -> bool:
|
||||||
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
@@ -19,6 +29,7 @@ class BMMinerS19(BMMiner, S19):
|
|||||||
data = json.dumps({"blink": "true"})
|
data = json.dumps({"blink": "true"})
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
data = await client.post(url, data=data, auth=auth)
|
data = await client.post(url, data=data, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
data = data.json()
|
data = data.json()
|
||||||
if data.get("code") == "B000":
|
if data.get("code") == "B000":
|
||||||
return True
|
return True
|
||||||
@@ -30,6 +41,7 @@ class BMMinerS19(BMMiner, S19):
|
|||||||
data = json.dumps({"blink": "false"})
|
data = json.dumps({"blink": "false"})
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
data = await client.post(url, data=data, auth=auth)
|
data = await client.post(url, data=data, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
data = data.json()
|
data = data.json()
|
||||||
if data.get("code") == "B100":
|
if data.get("code") == "B100":
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -10,8 +10,18 @@ class BMMinerS19Pro(BMMiner, S19Pro):
|
|||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
|
|
||||||
async def get_hostname(self) -> str:
|
async def get_hostname(self) -> str or None:
|
||||||
return "?"
|
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:
|
async def fault_light_on(self) -> bool:
|
||||||
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
@@ -19,6 +29,7 @@ class BMMinerS19Pro(BMMiner, S19Pro):
|
|||||||
data = json.dumps({"blink": "true"})
|
data = json.dumps({"blink": "true"})
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
data = await client.post(url, data=data, auth=auth)
|
data = await client.post(url, data=data, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
data = data.json()
|
data = data.json()
|
||||||
if data.get("code") == "B000":
|
if data.get("code") == "B000":
|
||||||
return True
|
return True
|
||||||
@@ -30,6 +41,7 @@ class BMMinerS19Pro(BMMiner, S19Pro):
|
|||||||
data = json.dumps({"blink": "false"})
|
data = json.dumps({"blink": "false"})
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
data = await client.post(url, data=data, auth=auth)
|
data = await client.post(url, data=data, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
data = data.json()
|
data = data.json()
|
||||||
if data.get("code") == "B100":
|
if data.get("code") == "B100":
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -10,8 +10,18 @@ class BMMinerS19a(BMMiner, S19a):
|
|||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
|
|
||||||
async def get_hostname(self) -> str:
|
async def get_hostname(self) -> str or None:
|
||||||
return "?"
|
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:
|
async def fault_light_on(self) -> bool:
|
||||||
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
@@ -19,6 +29,7 @@ class BMMinerS19a(BMMiner, S19a):
|
|||||||
data = json.dumps({"blink": "true"})
|
data = json.dumps({"blink": "true"})
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
data = await client.post(url, data=data, auth=auth)
|
data = await client.post(url, data=data, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
data = data.json()
|
data = data.json()
|
||||||
if data.get("code") == "B000":
|
if data.get("code") == "B000":
|
||||||
return True
|
return True
|
||||||
@@ -30,6 +41,7 @@ class BMMinerS19a(BMMiner, S19a):
|
|||||||
data = json.dumps({"blink": "false"})
|
data = json.dumps({"blink": "false"})
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
data = await client.post(url, data=data, auth=auth)
|
data = await client.post(url, data=data, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
data = data.json()
|
data = data.json()
|
||||||
if data.get("code") == "B100":
|
if data.get("code") == "B100":
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -10,8 +10,18 @@ class BMMinerS19j(BMMiner, S19j):
|
|||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
|
|
||||||
async def get_hostname(self) -> str:
|
async def get_hostname(self) -> str or None:
|
||||||
return "?"
|
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:
|
async def fault_light_on(self) -> bool:
|
||||||
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
@@ -19,6 +29,7 @@ class BMMinerS19j(BMMiner, S19j):
|
|||||||
data = json.dumps({"blink": "true"})
|
data = json.dumps({"blink": "true"})
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
data = await client.post(url, data=data, auth=auth)
|
data = await client.post(url, data=data, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
data = data.json()
|
data = data.json()
|
||||||
if data.get("code") == "B000":
|
if data.get("code") == "B000":
|
||||||
return True
|
return True
|
||||||
@@ -30,6 +41,7 @@ class BMMinerS19j(BMMiner, S19j):
|
|||||||
data = json.dumps({"blink": "false"})
|
data = json.dumps({"blink": "false"})
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
data = await client.post(url, data=data, auth=auth)
|
data = await client.post(url, data=data, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
data = data.json()
|
data = data.json()
|
||||||
if data.get("code") == "B100":
|
if data.get("code") == "B100":
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -10,8 +10,18 @@ class BMMinerS19jPro(BMMiner, S19jPro):
|
|||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
|
|
||||||
async def get_hostname(self) -> str:
|
async def get_hostname(self) -> str or None:
|
||||||
return "?"
|
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:
|
async def fault_light_on(self) -> bool:
|
||||||
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
@@ -19,6 +29,7 @@ class BMMinerS19jPro(BMMiner, S19jPro):
|
|||||||
data = json.dumps({"blink": "true"})
|
data = json.dumps({"blink": "true"})
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
data = await client.post(url, data=data, auth=auth)
|
data = await client.post(url, data=data, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
data = data.json()
|
data = data.json()
|
||||||
if data.get("code") == "B000":
|
if data.get("code") == "B000":
|
||||||
return True
|
return True
|
||||||
@@ -30,6 +41,7 @@ class BMMinerS19jPro(BMMiner, S19jPro):
|
|||||||
data = json.dumps({"blink": "false"})
|
data = json.dumps({"blink": "false"})
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
data = await client.post(url, data=data, auth=auth)
|
data = await client.post(url, data=data, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
data = data.json()
|
data = data.json()
|
||||||
if data.get("code") == "B100":
|
if data.get("code") == "B100":
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -10,8 +10,18 @@ class BMMinerT19(BMMiner, T19):
|
|||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
|
|
||||||
async def get_hostname(self) -> str:
|
async def get_hostname(self) -> str or None:
|
||||||
return "?"
|
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:
|
async def fault_light_on(self) -> bool:
|
||||||
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
@@ -19,6 +29,7 @@ class BMMinerT19(BMMiner, T19):
|
|||||||
data = json.dumps({"blink": "true"})
|
data = json.dumps({"blink": "true"})
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
data = await client.post(url, data=data, auth=auth)
|
data = await client.post(url, data=data, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
data = data.json()
|
data = data.json()
|
||||||
if data.get("code") == "B000":
|
if data.get("code") == "B000":
|
||||||
return True
|
return True
|
||||||
@@ -30,6 +41,7 @@ class BMMinerT19(BMMiner, T19):
|
|||||||
data = json.dumps({"blink": "false"})
|
data = json.dumps({"blink": "false"})
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
data = await client.post(url, data=data, auth=auth)
|
data = await client.post(url, data=data, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
data = data.json()
|
data = data.json()
|
||||||
if data.get("code") == "B100":
|
if data.get("code") == "B100":
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user