code format with black
This commit is contained in:
parent
92321a3b4e
commit
d467d79bdf
21
csdr.py
21
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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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"]:
|
||||
|
@ -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]),
|
||||
|
Loading…
Reference in New Issue
Block a user