From 560af8aeb0298dbdbdea57824ae84cbbd8c359de Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Mon, 15 Aug 2022 00:03:12 +0100 Subject: [PATCH] Lower max_chans to length of LIST if it's shorter --- modules/chankeep.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/chankeep.py b/modules/chankeep.py index 896928c..c49d4dd 100644 --- a/modules/chankeep.py +++ b/modules/chankeep.py @@ -303,6 +303,8 @@ def keepChannels(net, listinfo, mean, sigrelay, relay): # else: # newNums = [] flist = [i[0] for i in listinfo] + if len(flist) > max_chans: + max_chans = len(flist) chosen = sorted(flist, reverse=True, key=lambda x: x[1])[:max_chans] debug(f"keepChannels() {net}: joining {len(chosen)}/{len(flist)} channels") trace(f"keepChannels() {net}: joining:{chosen}") @@ -315,6 +317,8 @@ def keepChannels(net, listinfo, mean, sigrelay, relay): # else: # newNums = [] siglist = [i[0] for i in listinfo if int(i[1]) > mean] + if len(siglist) > max_chans: + max_chans = len(siglist) chosen = sorted(siglist, reverse=True, key=lambda x: x[1])[:max_chans] debug(f"keepChannels() {net}: joining {len(chosen)}/{len(siglist)} channels") trace(f"keepChannels() {net}: joining:{chosen}")