diff --git a/owrx/bookmarks.py b/owrx/bookmarks.py index 3e90a85..1456c8f 100644 --- a/owrx/bookmarks.py +++ b/owrx/bookmarks.py @@ -54,7 +54,6 @@ class Bookmarks(object): return [] return [] - def getBookmarks(self, range): (lo, hi) = range return [b for b in self.bookmarks if lo <= b.getFrequency() <= hi] diff --git a/owrx/command.py b/owrx/command.py index c9b4a66..97c0d55 100644 --- a/owrx/command.py +++ b/owrx/command.py @@ -58,7 +58,7 @@ class Option(CommandMapping): def map(self, value): if value is not None: if isinstance(value, str) and " " in value: - template = "{0} \"{1}\"" + template = '{0} "{1}"' else: template = "{0} {1}" return template.format(self.option, value) diff --git a/owrx/connection.py b/owrx/connection.py index 8dc1f9a..355181c 100644 --- a/owrx/connection.py +++ b/owrx/connection.py @@ -186,7 +186,7 @@ class OpenWebRxReceiverClient(Client): # keep trying until we find a suitable SDR if self.sdr.getState() == SdrSource.STATE_FAILED: - self.write_log_message("SDR device \"{0}\" has failed, selecting new device".format(self.sdr.getName())) + self.write_log_message('SDR device "{0}" has failed, selecting new device'.format(self.sdr.getName())) else: break diff --git a/owrx/controllers.py b/owrx/controllers.py index 3b636a2..a26ebc3 100644 --- a/owrx/controllers.py +++ b/owrx/controllers.py @@ -91,7 +91,7 @@ class AssetsController(Controller): class OwrxAssetsController(AssetsController): def openFile(self, file): - return pkg_resources.resource_stream('htdocs', file) + return pkg_resources.resource_stream("htdocs", file) class AprsSymbolsController(AssetsController): diff --git a/owrx/dsp.py b/owrx/dsp.py index a42ef7f..4638d09 100644 --- a/owrx/dsp.py +++ b/owrx/dsp.py @@ -21,7 +21,7 @@ class DspManager(csdr.output): self.localProps = ( self.sdrSource.getProps() - .collect( + .collect( "audio_compression", "fft_compression", "digimodes_fft_size", @@ -35,7 +35,7 @@ class DspManager(csdr.output): "temporary_directory", "center_freq", ) - .defaults(PropertyManager.getSharedInstance()) + .defaults(PropertyManager.getSharedInstance()) ) self.dsp = csdr.dsp(self) diff --git a/owrx/feature.py b/owrx/feature.py index 3fe2d53..00932df 100644 --- a/owrx/feature.py +++ b/owrx/feature.py @@ -223,9 +223,11 @@ class FeatureDetector(object): def _has_soapy_driver(self, driver): process = subprocess.Popen(["SoapySDRUtil", "--info"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) driverRegex = re.compile("^Module found: .*lib(.*)Support.so") + def matchLine(line): matches = driverRegex.match(line.decode()) return matches is not None and matches.group(1) == driver + lines = [matchLine(line) for line in process.stdout] return reduce(or_, lines, False) diff --git a/owrx/source/__init__.py b/owrx/source/__init__.py index a1e0068..c42fbf6 100644 --- a/owrx/source/__init__.py +++ b/owrx/source/__init__.py @@ -226,6 +226,7 @@ class SdrSource(ABC): if self.spectrumThread is None: # local import due to circular depencency from owrx.fft import SpectrumThread + self.spectrumThread = SpectrumThread(self) self.spectrumThread.start() diff --git a/owrx/source/airspy.py b/owrx/source/airspy.py index 3882b34..571302b 100644 --- a/owrx/source/airspy.py +++ b/owrx/source/airspy.py @@ -5,9 +5,7 @@ from .soapy import SoapyConnectorSource class AirspySource(SoapyConnectorSource): def __init__(self, id, props, port): super().__init__(id, props, port) - self.getCommandMapper().setMappings({ - "bias_tee": Flag("-t biastee=true") - }) + self.getCommandMapper().setMappings({"bias_tee": Flag("-t biastee=true")}) def getDriver(self): return "airspy" diff --git a/owrx/source/connector.py b/owrx/source/connector.py index 0ba4476..0f6b77f 100644 --- a/owrx/source/connector.py +++ b/owrx/source/connector.py @@ -13,17 +13,19 @@ class ConnectorSource(SdrSource): super().__init__(id, props, port) self.controlSocket = None self.controlPort = getAvailablePort() - self.getCommandMapper().setMappings({ - "samp_rate": Option("-s"), - "tuner_freq": Option("-f"), - "port": Option("-p"), - "controlPort": Option("-c"), - "device": Option("-d"), - "iqswap": Flag("-i"), - "rtltcp_compat": Flag("-r"), - "ppm": Option("-p"), - "rf_gain": Option("-g") - }) + self.getCommandMapper().setMappings( + { + "samp_rate": Option("-s"), + "tuner_freq": Option("-f"), + "port": Option("-p"), + "controlPort": Option("-c"), + "device": Option("-d"), + "iqswap": Flag("-i"), + "rtltcp_compat": Flag("-r"), + "ppm": Option("-p"), + "rf_gain": Option("-g"), + } + ) def getEventNames(self): return super().getEventNames() + [ @@ -40,9 +42,9 @@ class ConnectorSource(SdrSource): 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 + (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) diff --git a/owrx/source/direct.py b/owrx/source/direct.py index a2d0a2c..0dd338f 100644 --- a/owrx/source/direct.py +++ b/owrx/source/direct.py @@ -8,7 +8,11 @@ logger = logging.getLogger(__name__) class DirectSource(SdrSource, metaclass=ABCMeta): def onPropertyChange(self, name, value): - logger.debug("restarting sdr source due to property change: {0} changed to {1}".format(name, value)) + logger.debug( + "restarting sdr source due to property change: {0} changed to {1}".format( + name, value + ) + ) self.stop() self.sleepOnRestart() self.start() diff --git a/owrx/source/fifi.py b/owrx/source/fifi.py index 07f267a..c058164 100644 --- a/owrx/source/fifi.py +++ b/owrx/source/fifi.py @@ -5,15 +5,12 @@ from .direct import DirectSource class FifiSdrSource(DirectSource): def __init__(self, id, props, port): super().__init__(id, props, port) - self.getCommandMapper().setBase("arecord").setMappings({ - "device": Option("-D"), - "samp_rate": Option("-r") - }).setStatic("-f S16_LE -c2 -") + self.getCommandMapper().setBase("arecord").setMappings( + {"device": Option("-D"), "samp_rate": Option("-r")} + ).setStatic("-f S16_LE -c2 -") def getEventNames(self): - return super().getEventNames() + [ - "device" - ] + return super().getEventNames() + ["device"] def getFormatConversion(self): return "csdr convert_s16_f | csdr gain_ff 30" diff --git a/owrx/source/hackrf.py b/owrx/source/hackrf.py index 5a576e9..0850e11 100644 --- a/owrx/source/hackrf.py +++ b/owrx/source/hackrf.py @@ -5,13 +5,15 @@ from owrx.command import Flag, Option class HackrfSource(DirectSource): def __init__(self, id, props, port): super().__init__(id, props, port) - self.getCommandMapper().setBase("hackrf_transfer").setMappings({ - "samp_rate": Option("-s"), - "tuner_freq": Option("-f"), - "rf_gain": Option("-g"), - "lna_gain": Option("-l"), - "rf_amp": Option("-a") - }).setStatic("-r-") + self.getCommandMapper().setBase("hackrf_transfer").setMappings( + { + "samp_rate": Option("-s"), + "tuner_freq": Option("-f"), + "rf_gain": Option("-g"), + "lna_gain": Option("-l"), + "rf_amp": Option("-a"), + } + ).setStatic("-r-") def getEventNames(self): return super().getEventNames() + [ diff --git a/owrx/source/resampler.py b/owrx/source/resampler.py index f2f5e87..457c399 100644 --- a/owrx/source/resampler.py +++ b/owrx/source/resampler.py @@ -33,7 +33,7 @@ class Resampler(DirectSource): "csdr fir_decimate_cc {decimation} {ddc_transition_bw} HAMMING".format( decimation=self.decimation, ddc_transition_bw=self.transition_bw ), - self.getNmuxCommand() + self.getNmuxCommand(), ] def activateProfile(self, profile_id=None): diff --git a/owrx/source/soapy.py b/owrx/source/soapy.py index 2f090a8..40510f6 100644 --- a/owrx/source/soapy.py +++ b/owrx/source/soapy.py @@ -7,14 +7,13 @@ from .connector import ConnectorSource class SoapyConnectorSource(ConnectorSource, metaclass=ABCMeta): def __init__(self, id, props, port): super().__init__(id, props, port) - self.getCommandMapper().setBase("soapy_connector").setMappings({ - "antenna": Option("-a") - }) + self.getCommandMapper().setBase("soapy_connector").setMappings({"antenna": Option("-a")}) """ must be implemented by child classes to be able to build a driver-based device selector by default. return value must be the corresponding soapy driver identifier. """ + @abstractmethod def getDriver(self): pass @@ -25,7 +24,6 @@ class SoapyConnectorSource(ConnectorSource, metaclass=ABCMeta): ] def parseDeviceString(self, dstr): - def decodeComponent(c): kv = c.split("=", 1) if len(kv) < 2: @@ -36,7 +34,6 @@ class SoapyConnectorSource(ConnectorSource, metaclass=ABCMeta): return [decodeComponent(c) for c in dstr.split(",")] def encodeDeviceString(self, dobj): - def encodeComponent(c): if isinstance(c, str): return c @@ -49,6 +46,7 @@ class SoapyConnectorSource(ConnectorSource, metaclass=ABCMeta): this method always attempts to inject a driver= part into the soapysdr query, depending on what connector was used. this prevents the soapy_connector from using the wrong device in scenarios where there's no same-type sdrs. """ + def getCommandValues(self): values = super().getCommandValues() if "device" in values and values["device"] is not None: diff --git a/setup.py b/setup.py index ce53000..4623def 100644 --- a/setup.py +++ b/setup.py @@ -6,9 +6,7 @@ setup( name="OpenWebRX", version=str(strictversion), packages=find_namespace_packages(include=["owrx", "csdr", "htdocs"]), - package_data={ - "htdocs": [f[len("htdocs/"):] for f in glob("htdocs/**/*", recursive=True)] - }, + package_data={"htdocs": [f[len("htdocs/") :] for f in glob("htdocs/**/*", recursive=True)]}, entry_points={"console_scripts": ["openwebrx=owrx.__main__:main"]}, # use the github page for now url="https://github.com/jketterl/openwebrx",