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