run black

This commit is contained in:
Jakob Ketterl 2019-11-23 01:12:21 +01:00
parent 91669a7fda
commit 9246500c95
7 changed files with 72 additions and 34 deletions

View File

@ -26,6 +26,7 @@ class Bookmark(object):
class Bookmarks(object): class Bookmarks(object):
sharedInstance = None sharedInstance = None
@staticmethod @staticmethod
def getSharedInstance(): def getSharedInstance():
if Bookmarks.sharedInstance is None: if Bookmarks.sharedInstance is None:

View File

@ -242,7 +242,7 @@ class OpenWebRxReceiverClient(Client):
self.send(bytes([0x03]) + data) self.send(bytes([0x03]) + data)
def write_secondary_demod(self, data): def write_secondary_demod(self, data):
message = data.decode('ascii') message = data.decode("ascii")
self.send({"type": "secondary_demod", "value": message}) self.send({"type": "secondary_demod", "value": message})
def write_secondary_dsp_config(self, cfg): def write_secondary_dsp_config(self, cfg):

View File

@ -87,7 +87,7 @@ class FeatureDetector(object):
return inspect.getdoc(self._get_requirement_method(requirement)) return inspect.getdoc(self._get_requirement_method(requirement))
def command_is_runnable(self, command): def command_is_runnable(self, command):
tmp_dir = PropertyManager.getSharedInstance()['temporary_directory'] tmp_dir = PropertyManager.getSharedInstance()["temporary_directory"]
cmd = shlex.split(command) cmd = shlex.split(command)
try: try:
process = subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, cwd=tmp_dir) process = subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, cwd=tmp_dir)

View File

@ -69,13 +69,7 @@ class PskReporter(object):
def spotEquals(self, s1, s2): def spotEquals(self, s1, s2):
keys = ["callsign", "timestamp", "locator", "mode", "msg"] keys = ["callsign", "timestamp", "locator", "mode", "msg"]
return reduce( return reduce(and_, map(lambda key: s1[key] == s2[key], keys))
and_,
map(
lambda key: s1[key] == s2[key],
keys
)
)
def spot(self, spot): def spot(self, spot):
if not spot["mode"] in PskReporter.supportedModes: if not spot["mode"] in PskReporter.supportedModes:

View File

@ -206,12 +206,12 @@ class ServiceHandler(object):
def isSupported(self, mode): def isSupported(self, mode):
# TODO this should be in a more central place (the frontend also needs this) # TODO this should be in a more central place (the frontend also needs this)
requirements = { requirements = {
'ft8': 'wsjt-x', "ft8": "wsjt-x",
'ft4': 'wsjt-x', "ft4": "wsjt-x",
'jt65': 'wsjt-x', "jt65": "wsjt-x",
'jt9': 'wsjt-x', "jt9": "wsjt-x",
'wspr': 'wsjt-x', "wspr": "wsjt-x",
'packet': 'packet', "packet": "packet",
} }
fd = FeatureDetector() 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 # resampler goes in after the services since it must not be shutdown as long as the services are still running
self.services.append(resampler) self.services.append(resampler)
def optimizeResampling(self, freqs, bandwidth): def optimizeResampling(self, freqs, bandwidth):
freqs = sorted(freqs, key=lambda f: f["frequency"]) freqs = sorted(freqs, key=lambda f: f["frequency"])
distances = [ distances = [
@ -380,6 +379,7 @@ class AprsHandler(object):
class Services(object): class Services(object):
handlers = [] handlers = []
@staticmethod @staticmethod
def start(): def start():
if not PropertyManager.getSharedInstance()["services_enabled"]: if not PropertyManager.getSharedInstance()["services_enabled"]:

View File

@ -119,9 +119,7 @@ class SdrSource(object):
self.props = props self.props = props
self.profile_id = None self.profile_id = None
self.activateProfile() self.activateProfile()
self.rtlProps = self.props.collect( self.rtlProps = self.props.collect(*self.getEventNames()).defaults(PropertyManager.getSharedInstance())
*self.getEventNames()
).defaults(PropertyManager.getSharedInstance())
self.wireEvents() self.wireEvents()
self.port = port self.port = port
@ -136,7 +134,18 @@ class SdrSource(object):
self.busyState = SdrSource.BUSYSTATE_IDLE self.busyState = SdrSource.BUSYSTATE_IDLE
def getEventNames(self): 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 wireEvents(self):
def restart(name, value): def restart(name, value):
@ -206,9 +215,7 @@ class SdrSource(object):
props = self.rtlProps props = self.rtlProps
cmd = self.getCommand().format( cmd = self.getCommand().format(**self.getCommandValues())
**self.getCommandValues()
)
format_conversion = self.getFormatConversion() format_conversion = self.getFormatConversion()
if format_conversion is not None: if format_conversion is not None:
@ -459,11 +466,16 @@ class ConnectorSource(SdrSource):
def reconfigure(prop, value): def reconfigure(prop, value):
if self.monitor is None: if self.monitor is None:
return 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"] freq = self.rtlProps["center_freq"] + self.rtlProps["lfo_offset"]
self.sendControlMessage("center_freq", freq) self.sendControlMessage("center_freq", freq)
else: else:
self.sendControlMessage(prop, value) self.sendControlMessage(prop, value)
self.rtlProps.wire(reconfigure) self.rtlProps.wire(reconfigure)
def postStart(self): def postStart(self):
@ -486,11 +498,21 @@ class ConnectorSource(SdrSource):
class RtlSdrConnectorSource(ConnectorSource): class RtlSdrConnectorSource(ConnectorSource):
def getEventNames(self): 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): def getCommand(self):
cmd = "rtl_connector -p {port} -c {controlPort}".format(port=self.port, controlPort=self.controlPort) +\ cmd = (
" -s {samp_rate} -f {tuner_freq} -g {rf_gain} -P {ppm} -d {device}" "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"]: if self.rtlProps["iqswap"]:
cmd += " -i" cmd += " -i"
return cmd return cmd
@ -498,11 +520,22 @@ class RtlSdrConnectorSource(ConnectorSource):
class SdrplayConnectorSource(ConnectorSource): class SdrplayConnectorSource(ConnectorSource):
def getEventNames(self): 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): def getCommand(self):
cmd = "soapy_connector -p {port} -c {controlPort}".format(port=self.port, controlPort=self.controlPort) +\ cmd = (
" -s {samp_rate} -f {tuner_freq} -g \"{rf_gain}\" -P {ppm} -a \"{antenna}\" -d \"{device}\"" "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"]: if self.rtlProps["iqswap"]:
cmd += " -i" cmd += " -i"
return cmd return cmd
@ -510,11 +543,22 @@ class SdrplayConnectorSource(ConnectorSource):
class AirspyConnectorSource(ConnectorSource): class AirspyConnectorSource(ConnectorSource):
def getEventNames(self): 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): def getCommand(self):
cmd = "soapy_connector -p {port} -c {controlPort}".format(port=self.port, controlPort=self.controlPort) + \ cmd = (
" -s {samp_rate} -f {tuner_freq} -g \"{rf_gain}\" -P {ppm} -d \"{device}\"" "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"]: if self.rtlProps["iqswap"]:
cmd += " -i" cmd += " -i"
if self.rtlProps["bias_tee"]: if self.rtlProps["bias_tee"]:

View File

@ -120,7 +120,6 @@ class WebSocketConnection(object):
self._sendBytes(data_to_send) self._sendBytes(data_to_send)
def _sendBytes(self, data_to_send): def _sendBytes(self, data_to_send):
def chunks(l, n): def chunks(l, n):
"""Yield successive n-sized chunks from l.""" """Yield successive n-sized chunks from l."""
for i in range(0, len(l), n): for i in range(0, len(l), n):