prevent KeyError by checking for key existence

This commit is contained in:
Jakob Ketterl 2020-12-30 17:46:13 +01:00
parent f4b9decd23
commit 341b94b9ff

View File

@ -28,35 +28,41 @@ class DspManager(csdr.output, SdrSourceEventClient):
self.props = PropertyStack() self.props = PropertyStack()
# local demodulator properties not forwarded to the sdr # local demodulator properties not forwarded to the sdr
self.props.addLayer(0, PropertyLayer().filter( self.props.addLayer(
"output_rate", 0,
"hd_output_rate", PropertyLayer().filter(
"squelch_level", "output_rate",
"secondary_mod", "hd_output_rate",
"low_cut", "squelch_level",
"high_cut", "secondary_mod",
"offset_freq", "low_cut",
"mod", "high_cut",
"secondary_offset_freq", "offset_freq",
"dmr_filter", "mod",
)) "secondary_offset_freq",
"dmr_filter",
),
)
# properties that we inherit from the sdr # properties that we inherit from the sdr
self.props.addLayer(1, self.sdrSource.getProps().filter( self.props.addLayer(
"audio_compression", 1,
"fft_compression", self.sdrSource.getProps().filter(
"digimodes_fft_size", "audio_compression",
"csdr_dynamic_bufsize", "fft_compression",
"csdr_print_bufsizes", "digimodes_fft_size",
"csdr_through", "csdr_dynamic_bufsize",
"digimodes_enable", "csdr_print_bufsizes",
"samp_rate", "csdr_through",
"digital_voice_unvoiced_quality", "digimodes_enable",
"temporary_directory", "samp_rate",
"center_freq", "digital_voice_unvoiced_quality",
"start_mod", "temporary_directory",
"start_freq", "center_freq",
"wfm_deemphasis_tau", "start_mod",
)) "start_freq",
"wfm_deemphasis_tau",
),
)
self.dsp = csdr.dsp(self) self.dsp = csdr.dsp(self)
self.dsp.nc_port = self.sdrSource.getPort() self.dsp.nc_port = self.sdrSource.getPort()
@ -72,7 +78,12 @@ class DspManager(csdr.output, SdrSourceEventClient):
self.dsp.set_bpf(*bpf) self.dsp.set_bpf(*bpf)
def set_dial_freq(changes): def set_dial_freq(changes):
if self.props["center_freq"] is None or self.props["offset_freq"] is None: if (
"center_freq" not in self.props
or self.props["center_freq"] is None
or "offset_freq" not in self.props
or self.props["offset_freq"] is None
):
return return
freq = self.props["center_freq"] + self.props["offset_freq"] freq = self.props["center_freq"] + self.props["offset_freq"]
for parser in self.parsers.values(): for parser in self.parsers.values():