Skip to content

Commit 6c46a7c

Browse files
committed
bug: handle cases where hashboards and fans can be None with unknown types
1 parent 49f4217 commit 6c46a7c

File tree

17 files changed

+102
-1
lines changed

17 files changed

+102
-1
lines changed

pyasic/miners/backends/antminer.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ async def _get_errors(self, web_summary: dict = None) -> List[MinerErrorData]:
252252
return errors
253253

254254
async def _get_hashboards(self) -> List[HashBoard]:
255+
if self.expected_hashboards is None:
256+
return []
257+
255258
hashboards = [
256259
HashBoard(slot=idx, expected_chips=self.expected_chips)
257260
for idx in range(self.expected_hashboards)
@@ -565,6 +568,9 @@ async def _get_hostname(self, web_get_system_info: dict = None) -> Optional[str]
565568
pass
566569

567570
async def _get_fans(self, rpc_stats: dict = None) -> List[Fan]:
571+
if self.expected_fans is None:
572+
return []
573+
568574
if rpc_stats is None:
569575
try:
570576
rpc_stats = await self.rpc.stats()
@@ -593,6 +599,8 @@ async def _get_fans(self, rpc_stats: dict = None) -> List[Fan]:
593599
return fans_data
594600

595601
async def _get_hashboards(self, rpc_stats: dict = None) -> List[HashBoard]:
602+
if self.expected_hashboards is None:
603+
return []
596604
hashboards = []
597605

598606
if rpc_stats is None:

pyasic/miners/backends/auradine.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ async def _get_hashrate(self, rpc_summary: dict = None) -> Optional[AlgoHashRate
303303
async def _get_hashboards(
304304
self, rpc_devs: dict = None, web_ipreport: dict = None
305305
) -> List[HashBoard]:
306+
if self.expected_hashboards is None:
307+
return []
308+
306309
hashboards = [
307310
HashBoard(slot=i, expected_chips=self.expected_chips)
308311
for i in range(self.expected_hashboards)
@@ -382,6 +385,9 @@ async def _get_wattage_limit(
382385
pass
383386

384387
async def _get_fans(self, web_fan: dict = None) -> List[Fan]:
388+
if self.expected_fans is None:
389+
return []
390+
385391
if web_fan is None:
386392
try:
387393
web_fan = await self.web.get_fan()

pyasic/miners/backends/avalonminer.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ async def _get_hashrate(self, rpc_devs: dict = None) -> Optional[AlgoHashRate]:
212212
pass
213213

214214
async def _get_hashboards(self, rpc_stats: dict = None) -> List[HashBoard]:
215+
if self.expected_hashboards is None:
216+
return []
217+
215218
hashboards = [
216219
HashBoard(slot=i, expected_chips=self.expected_chips)
217220
for i in range(self.expected_hashboards)
@@ -326,6 +329,9 @@ async def _get_wattage(self, rpc_stats: dict = None) -> Optional[int]:
326329
pass
327330

328331
async def _get_fans(self, rpc_stats: dict = None) -> List[Fan]:
332+
if self.expected_fans is None:
333+
return []
334+
329335
if rpc_stats is None:
330336
try:
331337
rpc_stats = await self.rpc.stats()

pyasic/miners/backends/bfgminer.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ async def _get_hashrate(self, rpc_summary: dict = None) -> Optional[AlgoHashRate
129129
pass
130130

131131
async def _get_hashboards(self, rpc_stats: dict = None) -> List[HashBoard]:
132+
if self.expected_hashboards is None:
133+
return []
134+
132135
hashboards = []
133136

134137
if rpc_stats is None:
@@ -185,6 +188,9 @@ async def _get_hashboards(self, rpc_stats: dict = None) -> List[HashBoard]:
185188
return hashboards
186189

187190
async def _get_fans(self, rpc_stats: dict = None) -> List[Fan]:
191+
if self.expected_fans is None:
192+
return []
193+
188194
if rpc_stats is None:
189195
try:
190196
rpc_stats = await self.rpc.stats()

pyasic/miners/backends/bmminer.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ async def _get_hashrate(self, rpc_summary: dict = None) -> Optional[AlgoHashRate
133133
pass
134134

135135
async def _get_hashboards(self, rpc_stats: dict = None) -> List[HashBoard]:
136+
if self.expected_hashboards is None:
137+
return []
138+
136139
hashboards = []
137140

138141
if rpc_stats is None:
@@ -202,6 +205,9 @@ async def _get_hashboards(self, rpc_stats: dict = None) -> List[HashBoard]:
202205
return hashboards
203206

204207
async def _get_fans(self, rpc_stats: dict = None) -> List[Fan]:
208+
if self.expected_fans is None:
209+
return []
210+
205211
if rpc_stats is None:
206212
try:
207213
rpc_stats = await self.rpc.stats()

pyasic/miners/backends/braiins_os.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,9 @@ async def _get_hashboards(
376376
rpc_devdetails: dict = None,
377377
rpc_devs: dict = None,
378378
) -> List[HashBoard]:
379+
if self.expected_hashboards is None:
380+
return []
381+
379382
hashboards = [
380383
HashBoard(slot=i, expected_chips=self.expected_chips)
381384
for i in range(self.expected_hashboards)
@@ -473,6 +476,9 @@ async def _get_wattage_limit(self, rpc_tunerstatus: dict = None) -> Optional[int
473476
pass
474477

475478
async def _get_fans(self, rpc_fans: dict = None) -> List[Fan]:
479+
if self.expected_fans is None:
480+
return []
481+
476482
if rpc_fans is None:
477483
try:
478484
rpc_fans = await self.rpc.fans()
@@ -926,6 +932,9 @@ async def _get_expected_hashrate(
926932
pass
927933

928934
async def _get_hashboards(self, grpc_hashboards: dict = None) -> List[HashBoard]:
935+
if self.expected_hashboards is None:
936+
return []
937+
929938
hashboards = [
930939
HashBoard(slot=i, expected_chips=self.expected_chips)
931940
for i in range(self.expected_hashboards)
@@ -997,6 +1006,9 @@ async def _get_wattage_limit(
9971006
pass
9981007

9991008
async def _get_fans(self, grpc_cooling_state: dict = None) -> List[Fan]:
1009+
if self.expected_fans is None:
1010+
return []
1011+
10001012
if grpc_cooling_state is None:
10011013
try:
10021014
grpc_cooling_state = await self.web.get_cooling_state()

pyasic/miners/backends/btminer.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,9 @@ async def _get_hashrate(self, rpc_summary: dict = None) -> Optional[AlgoHashRate
412412
pass
413413

414414
async def _get_hashboards(self, rpc_devs: dict = None) -> List[HashBoard]:
415+
if self.expected_hashboards is None:
416+
return []
417+
415418
hashboards = [
416419
HashBoard(slot=i, expected_chips=self.expected_chips)
417420
for i in range(self.expected_hashboards)
@@ -490,6 +493,9 @@ async def _get_wattage_limit(self, rpc_summary: dict = None) -> Optional[int]:
490493
async def _get_fans(
491494
self, rpc_summary: dict = None, rpc_get_psu: dict = None
492495
) -> List[Fan]:
496+
if self.expected_fans is None:
497+
return []
498+
493499
if rpc_summary is None:
494500
try:
495501
rpc_summary = await self.rpc.summary()

pyasic/miners/backends/elphapex.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ async def _get_errors(self, web_summary: dict = None) -> List[MinerErrorData]:
209209
return errors
210210

211211
async def _get_hashboards(self, web_stats: dict | None = None) -> List[HashBoard]:
212+
if self.expected_hashboards is None:
213+
return []
214+
212215
hashboards = [
213216
HashBoard(slot=idx, expected_chips=self.expected_chips)
214217
for idx in range(self.expected_hashboards)
@@ -317,6 +320,9 @@ async def _get_uptime(self, web_summary: dict = None) -> Optional[int]:
317320
pass
318321

319322
async def _get_fans(self, web_stats: dict = None) -> List[Fan]:
323+
if self.expected_fans is None:
324+
return []
325+
320326
if web_stats is None:
321327
try:
322328
web_stats = await self.web.stats()

pyasic/miners/backends/epic.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,9 @@ async def _get_fw_ver(self, web_summary: dict = None) -> Optional[str]:
283283
pass
284284

285285
async def _get_fans(self, web_summary: dict = None) -> List[Fan]:
286+
if self.expected_fans is None:
287+
return []
288+
286289
if web_summary is None:
287290
try:
288291
web_summary = await self.web.summary()
@@ -302,6 +305,9 @@ async def _get_fans(self, web_summary: dict = None) -> List[Fan]:
302305
async def _get_hashboards(
303306
self, web_summary: dict = None, web_capabilities: dict = None
304307
) -> List[HashBoard]:
308+
if self.expected_hashboards is None:
309+
return []
310+
305311
if web_summary is None:
306312
try:
307313
web_summary = await self.web.summary()

pyasic/miners/backends/espminer.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ async def _get_uptime(self, web_system_info: dict = None) -> Optional[int]:
141141
pass
142142

143143
async def _get_hashboards(self, web_system_info: dict = None) -> List[HashBoard]:
144+
if self.expected_hashboards is None:
145+
return []
146+
144147
if web_system_info is None:
145148
try:
146149
web_system_info = await self.web.system_info()
@@ -169,6 +172,9 @@ async def _get_hashboards(self, web_system_info: dict = None) -> List[HashBoard]
169172
return []
170173

171174
async def _get_fans(self, web_system_info: dict = None) -> List[Fan]:
175+
if self.expected_fans is None:
176+
return []
177+
172178
if web_system_info is None:
173179
try:
174180
web_system_info = await self.web.system_info()

0 commit comments

Comments
 (0)