From 844deec0d3d2c00ed551f5cb442e328395019153 Mon Sep 17 00:00:00 2001 From: UpstreamData Date: Tue, 31 May 2022 16:54:56 -0600 Subject: [PATCH] add fault light command to X19 miners --- miners/antminer/bmminer/X19/S19.py | 25 +++++++++++++++++++++++++ miners/antminer/bmminer/X19/S19_Pro.py | 25 +++++++++++++++++++++++++ miners/antminer/bmminer/X19/S19a.py | 25 +++++++++++++++++++++++++ miners/antminer/bmminer/X19/S19j.py | 25 +++++++++++++++++++++++++ miners/antminer/bmminer/X19/S19j_Pro.py | 25 +++++++++++++++++++++++++ miners/antminer/bmminer/X19/T19.py | 25 +++++++++++++++++++++++++ 6 files changed, 150 insertions(+) diff --git a/miners/antminer/bmminer/X19/S19.py b/miners/antminer/bmminer/X19/S19.py index 84d8c08b..0d859c56 100644 --- a/miners/antminer/bmminer/X19/S19.py +++ b/miners/antminer/bmminer/X19/S19.py @@ -1,6 +1,9 @@ from miners._backends import BMMiner # noqa - Ignore access to _module from miners._types import S19 # noqa - Ignore access to _module +import httpx +import json + class BMMinerS19(BMMiner, S19): def __init__(self, ip: str) -> None: @@ -9,3 +12,25 @@ class BMMinerS19(BMMiner, S19): async def get_hostname(self) -> str: return "?" + + async def fault_light_on(self) -> bool: + url = f"http://{self.ip}/cgi-bin/blink.cgi" + auth = httpx.DigestAuth("root", "root") + 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 + return False + + async def fault_light_off(self) -> bool: + url = f"http://{self.ip}/cgi-bin/blink.cgi" + auth = httpx.DigestAuth("root", "root") + 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 + return False diff --git a/miners/antminer/bmminer/X19/S19_Pro.py b/miners/antminer/bmminer/X19/S19_Pro.py index f9479134..38c31216 100644 --- a/miners/antminer/bmminer/X19/S19_Pro.py +++ b/miners/antminer/bmminer/X19/S19_Pro.py @@ -1,6 +1,9 @@ from miners._backends import BMMiner # noqa - Ignore access to _module from miners._types import S19Pro # noqa - Ignore access to _module +import httpx +import json + class BMMinerS19Pro(BMMiner, S19Pro): def __init__(self, ip: str) -> None: @@ -9,3 +12,25 @@ class BMMinerS19Pro(BMMiner, S19Pro): async def get_hostname(self) -> str: return "?" + + async def fault_light_on(self) -> bool: + url = f"http://{self.ip}/cgi-bin/blink.cgi" + auth = httpx.DigestAuth("root", "root") + 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 + return False + + async def fault_light_off(self) -> bool: + url = f"http://{self.ip}/cgi-bin/blink.cgi" + auth = httpx.DigestAuth("root", "root") + 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 + return False diff --git a/miners/antminer/bmminer/X19/S19a.py b/miners/antminer/bmminer/X19/S19a.py index 50e2ed59..92dce153 100644 --- a/miners/antminer/bmminer/X19/S19a.py +++ b/miners/antminer/bmminer/X19/S19a.py @@ -1,6 +1,9 @@ from miners._backends import BMMiner # noqa - Ignore access to _module from miners._types import S19a # noqa - Ignore access to _module +import httpx +import json + class BMMinerS19a(BMMiner, S19a): def __init__(self, ip: str) -> None: @@ -9,3 +12,25 @@ class BMMinerS19a(BMMiner, S19a): async def get_hostname(self) -> str: return "?" + + async def fault_light_on(self) -> bool: + url = f"http://{self.ip}/cgi-bin/blink.cgi" + auth = httpx.DigestAuth("root", "root") + 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 + return False + + async def fault_light_off(self) -> bool: + url = f"http://{self.ip}/cgi-bin/blink.cgi" + auth = httpx.DigestAuth("root", "root") + 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 + return False diff --git a/miners/antminer/bmminer/X19/S19j.py b/miners/antminer/bmminer/X19/S19j.py index 17b95bfb..c3e20f7a 100644 --- a/miners/antminer/bmminer/X19/S19j.py +++ b/miners/antminer/bmminer/X19/S19j.py @@ -1,6 +1,9 @@ from miners._backends import BMMiner # noqa - Ignore access to _module from miners._types import S19j # noqa - Ignore access to _module +import httpx +import json + class BMMinerS19j(BMMiner, S19j): def __init__(self, ip: str) -> None: @@ -9,3 +12,25 @@ class BMMinerS19j(BMMiner, S19j): async def get_hostname(self) -> str: return "?" + + async def fault_light_on(self) -> bool: + url = f"http://{self.ip}/cgi-bin/blink.cgi" + auth = httpx.DigestAuth("root", "root") + 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 + return False + + async def fault_light_off(self) -> bool: + url = f"http://{self.ip}/cgi-bin/blink.cgi" + auth = httpx.DigestAuth("root", "root") + 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 + return False diff --git a/miners/antminer/bmminer/X19/S19j_Pro.py b/miners/antminer/bmminer/X19/S19j_Pro.py index c3e629f4..764111cf 100644 --- a/miners/antminer/bmminer/X19/S19j_Pro.py +++ b/miners/antminer/bmminer/X19/S19j_Pro.py @@ -1,6 +1,9 @@ from miners._backends import BMMiner # noqa - Ignore access to _module from miners._types import S19jPro # noqa - Ignore access to _module +import httpx +import json + class BMMinerS19jPro(BMMiner, S19jPro): def __init__(self, ip: str) -> None: @@ -9,3 +12,25 @@ class BMMinerS19jPro(BMMiner, S19jPro): async def get_hostname(self) -> str: return "?" + + async def fault_light_on(self) -> bool: + url = f"http://{self.ip}/cgi-bin/blink.cgi" + auth = httpx.DigestAuth("root", "root") + 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 + return False + + async def fault_light_off(self) -> bool: + url = f"http://{self.ip}/cgi-bin/blink.cgi" + auth = httpx.DigestAuth("root", "root") + 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 + return False diff --git a/miners/antminer/bmminer/X19/T19.py b/miners/antminer/bmminer/X19/T19.py index 5bd91fd2..c810316b 100644 --- a/miners/antminer/bmminer/X19/T19.py +++ b/miners/antminer/bmminer/X19/T19.py @@ -1,6 +1,9 @@ from miners._backends import BMMiner # noqa - Ignore access to _module from miners._types import T19 # noqa - Ignore access to _module +import httpx +import json + class BMMinerT19(BMMiner, T19): def __init__(self, ip: str) -> None: @@ -9,3 +12,25 @@ class BMMinerT19(BMMiner, T19): async def get_hostname(self) -> str: return "?" + + async def fault_light_on(self) -> bool: + url = f"http://{self.ip}/cgi-bin/blink.cgi" + auth = httpx.DigestAuth("root", "root") + 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 + return False + + async def fault_light_off(self) -> bool: + url = f"http://{self.ip}/cgi-bin/blink.cgi" + auth = httpx.DigestAuth("root", "root") + 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 + return False