From 9246500c95392aba0c78e4df1bfe4ab83c4dcff7 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sat, 23 Nov 2019 01:12:21 +0100 Subject: [PATCH] run black --- owrx/bookmarks.py | 1 + owrx/connection.py | 2 +- owrx/feature.py | 2 +- owrx/pskreporter.py | 8 +---- owrx/service.py | 14 ++++---- owrx/source.py | 78 +++++++++++++++++++++++++++++++++++---------- owrx/websocket.py | 1 - 7 files changed, 72 insertions(+), 34 deletions(-) diff --git a/owrx/bookmarks.py b/owrx/bookmarks.py index 9074088..f35d539 100644 --- a/owrx/bookmarks.py +++ b/owrx/bookmarks.py @@ -26,6 +26,7 @@ class Bookmark(object): class Bookmarks(object): sharedInstance = None + @staticmethod def getSharedInstance(): if Bookmarks.sharedInstance is None: diff --git a/owrx/connection.py b/owrx/connection.py index 770e27d..af0a3ec 100644 --- a/owrx/connection.py +++ b/owrx/connection.py @@ -242,7 +242,7 @@ class OpenWebRxReceiverClient(Client): self.send(bytes([0x03]) + data) def write_secondary_demod(self, data): - message = data.decode('ascii') + message = data.decode("ascii") self.send({"type": "secondary_demod", "value": message}) def write_secondary_dsp_config(self, cfg): diff --git a/owrx/feature.py b/owrx/feature.py index ece646a..602386a 100644 --- a/owrx/feature.py +++ b/owrx/feature.py @@ -87,7 +87,7 @@ class FeatureDetector(object): return inspect.getdoc(self._get_requirement_method(requirement)) def command_is_runnable(self, command): - tmp_dir = PropertyManager.getSharedInstance()['temporary_directory'] + tmp_dir = PropertyManager.getSharedInstance()["temporary_directory"] cmd = shlex.split(command) try: process = subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, cwd=tmp_dir) diff --git a/owrx/pskreporter.py b/owrx/pskreporter.py index 1ede006..da580f0 100644 --- a/owrx/pskreporter.py +++ b/owrx/pskreporter.py @@ -69,13 +69,7 @@ class PskReporter(object): def spotEquals(self, s1, s2): keys = ["callsign", "timestamp", "locator", "mode", "msg"] - return reduce( - and_, - map( - lambda key: s1[key] == s2[key], - keys - ) - ) + return reduce(and_, map(lambda key: s1[key] == s2[key], keys)) def spot(self, spot): if not spot["mode"] in PskReporter.supportedModes: diff --git a/owrx/service.py b/owrx/service.py index 179dffa..db9d65b 100644 --- a/owrx/service.py +++ b/owrx/service.py @@ -206,12 +206,12 @@ class ServiceHandler(object): def isSupported(self, mode): # TODO this should be in a more central place (the frontend also needs this) requirements = { - 'ft8': 'wsjt-x', - 'ft4': 'wsjt-x', - 'jt65': 'wsjt-x', - 'jt9': 'wsjt-x', - 'wspr': 'wsjt-x', - 'packet': 'packet', + "ft8": "wsjt-x", + "ft4": "wsjt-x", + "jt65": "wsjt-x", + "jt9": "wsjt-x", + "wspr": "wsjt-x", + "packet": "packet", } fd = FeatureDetector() @@ -298,7 +298,6 @@ class ServiceHandler(object): # resampler goes in after the services since it must not be shutdown as long as the services are still running self.services.append(resampler) - def optimizeResampling(self, freqs, bandwidth): freqs = sorted(freqs, key=lambda f: f["frequency"]) distances = [ @@ -380,6 +379,7 @@ class AprsHandler(object): class Services(object): handlers = [] + @staticmethod def start(): if not PropertyManager.getSharedInstance()["services_enabled"]: diff --git a/owrx/source.py b/owrx/source.py index 3a0eedf..fc228f5 100644 --- a/owrx/source.py +++ b/owrx/source.py @@ -119,9 +119,7 @@ class SdrSource(object): self.props = props self.profile_id = None self.activateProfile() - self.rtlProps = self.props.collect( - *self.getEventNames() - ).defaults(PropertyManager.getSharedInstance()) + self.rtlProps = self.props.collect(*self.getEventNames()).defaults(PropertyManager.getSharedInstance()) self.wireEvents() self.port = port @@ -136,7 +134,18 @@ class SdrSource(object): self.busyState = SdrSource.BUSYSTATE_IDLE def getEventNames(self): - return ["samp_rate", "nmux_memory", "center_freq", "ppm", "rf_gain", "lna_gain", "rf_amp", "antenna", "if_gain", "lfo_offset"] + return [ + "samp_rate", + "nmux_memory", + "center_freq", + "ppm", + "rf_gain", + "lna_gain", + "rf_amp", + "antenna", + "if_gain", + "lfo_offset", + ] def wireEvents(self): def restart(name, value): @@ -206,9 +215,7 @@ class SdrSource(object): props = self.rtlProps - cmd = self.getCommand().format( - **self.getCommandValues() - ) + cmd = self.getCommand().format(**self.getCommandValues()) format_conversion = self.getFormatConversion() if format_conversion is not None: @@ -459,11 +466,16 @@ class ConnectorSource(SdrSource): def reconfigure(prop, value): if self.monitor is None: return - if (prop == "center_freq" or prop == "lfo_offset") and "lfo_offset" in self.rtlProps and self.rtlProps["lfo_offset"] is not None: + if ( + (prop == "center_freq" or prop == "lfo_offset") + and "lfo_offset" in self.rtlProps + and self.rtlProps["lfo_offset"] is not None + ): freq = self.rtlProps["center_freq"] + self.rtlProps["lfo_offset"] self.sendControlMessage("center_freq", freq) else: self.sendControlMessage(prop, value) + self.rtlProps.wire(reconfigure) def postStart(self): @@ -486,11 +498,21 @@ class ConnectorSource(SdrSource): class RtlSdrConnectorSource(ConnectorSource): def getEventNames(self): - return ["samp_rate", "center_freq", "ppm", "rf_gain", "device", "iqswap", "lfo_offset"] + return [ + "samp_rate", + "center_freq", + "ppm", + "rf_gain", + "device", + "iqswap", + "lfo_offset", + ] def getCommand(self): - cmd = "rtl_connector -p {port} -c {controlPort}".format(port=self.port, controlPort=self.controlPort) +\ - " -s {samp_rate} -f {tuner_freq} -g {rf_gain} -P {ppm} -d {device}" + cmd = ( + "rtl_connector -p {port} -c {controlPort}".format(port=self.port, controlPort=self.controlPort) + + " -s {samp_rate} -f {tuner_freq} -g {rf_gain} -P {ppm} -d {device}" + ) if self.rtlProps["iqswap"]: cmd += " -i" return cmd @@ -498,11 +520,22 @@ class RtlSdrConnectorSource(ConnectorSource): class SdrplayConnectorSource(ConnectorSource): def getEventNames(self): - return ["samp_rate", "center_freq", "ppm", "rf_gain", "antenna", "device", "iqswap", "lfo_offset"] + return [ + "samp_rate", + "center_freq", + "ppm", + "rf_gain", + "antenna", + "device", + "iqswap", + "lfo_offset", + ] def getCommand(self): - cmd = "soapy_connector -p {port} -c {controlPort}".format(port=self.port, controlPort=self.controlPort) +\ - " -s {samp_rate} -f {tuner_freq} -g \"{rf_gain}\" -P {ppm} -a \"{antenna}\" -d \"{device}\"" + cmd = ( + "soapy_connector -p {port} -c {controlPort}".format(port=self.port, controlPort=self.controlPort) + + ' -s {samp_rate} -f {tuner_freq} -g "{rf_gain}" -P {ppm} -a "{antenna}" -d "{device}"' + ) if self.rtlProps["iqswap"]: cmd += " -i" return cmd @@ -510,11 +543,22 @@ class SdrplayConnectorSource(ConnectorSource): class AirspyConnectorSource(ConnectorSource): def getEventNames(self): - return ["samp_rate", "center_freq", "ppm", "rf_gain", "device", "iqswap", "lfo_offset", "bias_tee"] + return [ + "samp_rate", + "center_freq", + "ppm", + "rf_gain", + "device", + "iqswap", + "lfo_offset", + "bias_tee", + ] def getCommand(self): - cmd = "soapy_connector -p {port} -c {controlPort}".format(port=self.port, controlPort=self.controlPort) + \ - " -s {samp_rate} -f {tuner_freq} -g \"{rf_gain}\" -P {ppm} -d \"{device}\"" + cmd = ( + "soapy_connector -p {port} -c {controlPort}".format(port=self.port, controlPort=self.controlPort) + + ' -s {samp_rate} -f {tuner_freq} -g "{rf_gain}" -P {ppm} -d "{device}"' + ) if self.rtlProps["iqswap"]: cmd += " -i" if self.rtlProps["bias_tee"]: diff --git a/owrx/websocket.py b/owrx/websocket.py index 24ab02b..a5fb188 100644 --- a/owrx/websocket.py +++ b/owrx/websocket.py @@ -120,7 +120,6 @@ class WebSocketConnection(object): self._sendBytes(data_to_send) def _sendBytes(self, data_to_send): - def chunks(l, n): """Yield successive n-sized chunks from l.""" for i in range(0, len(l), n):