diff --git a/csdr.py b/csdr.py index 08a0c45..832d069 100644 --- a/csdr.py +++ b/csdr.py @@ -36,7 +36,7 @@ class output(object): def send_output(self, t, read_fn): if not self.supports_type(t): # TODO rewrite the output mechanism in a way that avoids producing unnecessary data - logger.warning('dumping output of type %s since it is not supported.', t) + logger.warning("dumping output of type %s since it is not supported.", t) threading.Thread(target=self.pump(read_fn, lambda x: None)).start() return self.receive_output(t, read_fn) @@ -131,18 +131,17 @@ class dsp(object): "csdr shift_addition_cc --fifo {shift_pipe}", "csdr fir_decimate_cc {decimation} {ddc_transition_bw} HAMMING", "csdr bandpass_fir_fft_cc --fifo {bpf_pipe} {bpf_transition_bw} HAMMING", - ] - if self.output.supports_type('smeter'): + if self.output.supports_type("smeter"): chain += [ - "csdr squelch_and_smeter_cc --fifo {squelch_pipe} --outfifo {smeter_pipe} 5 {smeter_report_every}", + "csdr squelch_and_smeter_cc --fifo {squelch_pipe} --outfifo {smeter_pipe} 5 {smeter_report_every}" ] if self.secondary_demodulator: - if self.output.supports_type('secondary_fft'): + if self.output.supports_type("secondary_fft"): chain += ["csdr tee {iqtee_pipe}"] chain += ["csdr tee {iqtee2_pipe}"] # early exit if we don't want audio - if not self.output.supports_type('audio'): + if not self.output.supports_type("audio"): return chain # safe some cpu cycles... no need to decimate if decimation factor is 1 last_decimation_block = ( @@ -282,7 +281,7 @@ class dsp(object): # if self.csdr_dynamic_bufsize: my_env["CSDR_DYNAMIC_BUFSIZE_ON"]="1"; if self.csdr_print_bufsizes: my_env["CSDR_PRINT_BUFSIZES"] = "1" - if self.output.supports_type('secondary_fft'): + if self.output.supports_type("secondary_fft"): secondary_command_fft = self.secondary_chain("fft") secondary_command_fft = secondary_command_fft.format( input_pipe=self.iqtee_pipe, @@ -572,7 +571,7 @@ class dsp(object): if self.csdr_print_bufsizes: my_env["CSDR_PRINT_BUFSIZES"] = "1" - out = subprocess.PIPE if self.output.supports_type('audio') else subprocess.DEVNULL + out = subprocess.PIPE if self.output.supports_type("audio") else subprocess.DEVNULL self.process = subprocess.Popen(command, stdout=out, shell=True, preexec_fn=os.setpgrp, env=my_env) def watch_thread(): @@ -584,10 +583,12 @@ class dsp(object): threading.Thread(target=watch_thread).start() - if self.output.supports_type('audio'): + if self.output.supports_type("audio"): self.output.send_output( "audio", - partial(self.process.stdout.read, int(self.get_fft_bytes_to_read()) if self.demodulator == "fft" else 256), + partial( + self.process.stdout.read, int(self.get_fft_bytes_to_read()) if self.demodulator == "fft" else 256 + ), ) # open control pipes for csdr diff --git a/owrx/metrics.py b/owrx/metrics.py index a8923d0..11f503f 100644 --- a/owrx/metrics.py +++ b/owrx/metrics.py @@ -10,21 +10,19 @@ class Metrics(object): def __init__(self): self.metrics = {} - def pushDecodes(self, band, mode, count = 1): + def pushDecodes(self, band, mode, count=1): if band is None: - band = 'unknown' + band = "unknown" else: band = band.getName() if mode is None: - mode = 'unknown' + mode = "unknown" if not band in self.metrics: self.metrics[band] = {} if not mode in self.metrics[band]: - self.metrics[band][mode] = { - "count": 0 - } + self.metrics[band][mode] = {"count": 0} self.metrics[band][mode]["count"] += count diff --git a/owrx/service.py b/owrx/service.py index fe6a4eb..b64e504 100644 --- a/owrx/service.py +++ b/owrx/service.py @@ -21,7 +21,7 @@ class ServiceOutput(output): threading.Thread(target=target).start() def supports_type(self, t): - return t == 'wsjt_demod' + return t == "wsjt_demod" class ServiceHandler(object): @@ -69,7 +69,11 @@ class ServiceHandler(object): cf = self.source.getProps()["center_freq"] srh = self.source.getProps()["samp_rate"] / 2 frequency_range = (cf - srh, cf + srh) - self.services = [self.setupService(dial["mode"], dial["frequency"]) for dial in Bandplan.getSharedInstance().collectDialFrequencies(frequency_range) if self.isSupported(dial["mode"])] + self.services = [ + self.setupService(dial["mode"], dial["frequency"]) + for dial in Bandplan.getSharedInstance().collectDialFrequencies(frequency_range) + if self.isSupported(dial["mode"]) + ] def setupService(self, mode, frequency): logger.debug("setting up service {0} on frequency {1}".format(mode, frequency)) @@ -92,6 +96,7 @@ class WsjtHandler(object): class ServiceManager(object): sharedInstance = None + @staticmethod def getSharedInstance(): if ServiceManager.sharedInstance is None: diff --git a/owrx/source.py b/owrx/source.py index 488ff47..8f5dc65 100644 --- a/owrx/source.py +++ b/owrx/source.py @@ -377,7 +377,7 @@ class SpectrumThread(csdr.output): self.dsp.start() def supports_type(self, t): - return t == 'audio' + return t == "audio" def receive_output(self, type, read_fn): if self.props["csdr_dynamic_bufsize"]: diff --git a/owrx/wsjt.py b/owrx/wsjt.py index 082e59f..e18257e 100644 --- a/owrx/wsjt.py +++ b/owrx/wsjt.py @@ -255,7 +255,7 @@ class WsjtParser(object): # '0052 -29 2.6 0.001486 0 G02CWT IO92 23' wsjt_msg = msg[29:].strip() self.parseWsprMessage(wsjt_msg) - Metrics.getSharedInstance().pushDecodes(self.band, 'WSPR') + Metrics.getSharedInstance().pushDecodes(self.band, "WSPR") return { "timestamp": self.parse_timestamp(msg[0:4], "%H%M"), "db": float(msg[5:8]),