From accf2a34ff16e27d8dc409e46b4606def335614b Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sun, 28 Jul 2019 11:45:28 +0200 Subject: [PATCH] fix exception when outside of band --- owrx/bands.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/owrx/bands.py b/owrx/bands.py index bc76b2a..e4cb5ef 100644 --- a/owrx/bands.py +++ b/owrx/bands.py @@ -51,8 +51,15 @@ class Bandplan(object): f.close() self.bands = [Band(d) for d in bands_json] + def findBands(self, freq): + return [band for band in self.bands if band.inBand(freq)] + def findBand(self, freq): - return next(band for band in self.bands if band.inBand(freq)) + bands = self.findBands(freq) + if bands: + return bands[0] + else: + return None def collectDialFrequencis(self, range): return [e for b in self.bands for e in b.getDialFrequencies(range)]