added better logging to testbench
This commit is contained in:
@@ -4,6 +4,7 @@ import json
|
||||
import hashlib
|
||||
import binascii
|
||||
import base64
|
||||
import logging
|
||||
|
||||
from passlib.handlers.md5_crypt import md5_crypt
|
||||
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
||||
@@ -205,7 +206,7 @@ class BTMinerAPI(BaseMinerAPI):
|
||||
break
|
||||
data += d
|
||||
except Exception as e:
|
||||
print(e)
|
||||
logging.info(f"{str(self.ip)}: {e}")
|
||||
|
||||
data = self.load_api_data(data)
|
||||
|
||||
@@ -219,7 +220,7 @@ class BTMinerAPI(BaseMinerAPI):
|
||||
try:
|
||||
data = parse_btminer_priviledge_data(self.current_token, data)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
logging.info(f"{str(self.ip)}: {e}")
|
||||
|
||||
if not ignore_errors:
|
||||
# if it fails to validate, it is likely an error
|
||||
|
||||
@@ -34,6 +34,7 @@ from API import APIError
|
||||
import asyncio
|
||||
import ipaddress
|
||||
import json
|
||||
import logging
|
||||
|
||||
from settings import MINER_FACTORY_GET_VERSION_RETRIES as GET_VERSION_RETRIES
|
||||
|
||||
@@ -107,7 +108,7 @@ class MinerFactory:
|
||||
|
||||
# handle the different API types
|
||||
if not api:
|
||||
print(ip)
|
||||
logging.warning(f"{str(ip)}: No API data found, using BraiinsOS.")
|
||||
miner = BOSMinerS9(str(ip))
|
||||
elif "BOSMiner" in api:
|
||||
miner = BOSMinerS9(str(ip))
|
||||
@@ -244,9 +245,9 @@ class MinerFactory:
|
||||
|
||||
# if there are errors, we just return None
|
||||
except APIError as e:
|
||||
print(e)
|
||||
logging.debug(f"{str(ip)}: {e}")
|
||||
except OSError as e:
|
||||
print(e)
|
||||
logging.debug(f"{str(ip)}: {e}")
|
||||
return model
|
||||
|
||||
async def _send_api_command(self, ip: ipaddress.ip_address or str, command: str):
|
||||
@@ -254,7 +255,7 @@ class MinerFactory:
|
||||
# get reader and writer streams
|
||||
reader, writer = await asyncio.open_connection(str(ip), 4028)
|
||||
except OSError as e:
|
||||
print(e)
|
||||
logging.warning(f"{str(ip)} - Command {command}: {e}")
|
||||
return {}
|
||||
|
||||
# create the command
|
||||
@@ -275,7 +276,7 @@ class MinerFactory:
|
||||
break
|
||||
data += d
|
||||
except Exception as e:
|
||||
print(e)
|
||||
logging.debug(f"{str(ip)}: {e}")
|
||||
|
||||
try:
|
||||
# some json from the API returns with a null byte (\x00) on the end
|
||||
@@ -353,5 +354,5 @@ class MinerFactory:
|
||||
if e.winerror == 121:
|
||||
return None
|
||||
else:
|
||||
print(ip, e)
|
||||
logging.debug(f"{str(ip)}: {e}")
|
||||
return None
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import ipaddress
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
from network.net_range import MinerNetworkRange
|
||||
from miners.miner_factory import MinerFactory
|
||||
@@ -165,9 +166,9 @@ async def ping_miner(
|
||||
continue
|
||||
except ConnectionRefusedError:
|
||||
# handle for other connection errors
|
||||
print(f"{str(ip)}: Connection Refused.")
|
||||
logging.debug(f"{str(ip)}: Connection Refused.")
|
||||
# ping failed, likely with an exception
|
||||
except Exception as e:
|
||||
print(e)
|
||||
logging.warning(f"{str(ip)}: {e}")
|
||||
continue
|
||||
return
|
||||
|
||||
@@ -16,5 +16,5 @@ whatsminer_pwd = "admin"
|
||||
### DEBUG MODE ###
|
||||
# change this to debug = true
|
||||
# to enable debug mode.
|
||||
# debug = false
|
||||
debug = true
|
||||
debug = false
|
||||
# debug = true
|
||||
|
||||
Reference in New Issue
Block a user