diff --git a/owrx/config.py b/owrx/config.py index 5e59b51..aa3e053 100644 --- a/owrx/config.py +++ b/owrx/config.py @@ -1,3 +1,5 @@ +import os + class Property(object): def __init__(self, value = None): self.value = value @@ -32,3 +34,21 @@ class PropertyManager(object): def getPropertyValue(self, name): return self.getProperty(name).getValue() + +class RequirementMissingException(Exception): + pass + +class FeatureDetector(object): + def detectAllFeatures(self): + print("Starting Feature detection") + self.detect_csdr() + self.detect_nmux() + print("Feature detection completed.") + + def detect_csdr(self): + if os.system("csdr 2> /dev/null") == 32512: #check for csdr + raise RequirementMissingException("You need to install \"csdr\" to run OpenWebRX!") + + def detect_nmux(self): + if os.system("nmux --help 2> /dev/null") == 32512: #check for nmux + raise RequirementMissingException("You need to install an up-to-date version of \"csdr\" that contains the \"nmux\" tool to run OpenWebRX! Please upgrade \"csdr\"!") diff --git a/server.py b/server.py index 5e14a01..436983f 100644 --- a/server.py +++ b/server.py @@ -1,23 +1,40 @@ from http.server import HTTPServer from owrx.http import RequestHandler -from owrx.config import PropertyManager -from owrx.source import RtlNmuxSource, SpectrumThread +from owrx.config import PropertyManager, FeatureDetector, RequirementMissingException +from owrx.source import RtlNmuxSource from socketserver import ThreadingMixIn class ThreadedHttpServer(ThreadingMixIn, HTTPServer): pass def main(): + print() + print("OpenWebRX - Open Source SDR Web App for Everyone! | for license see LICENSE file in the package") + print("_________________________________________________________________________________________________") + print() + print("Author contact info: Andras Retzler, HA7ILM ") + print() + cfg=__import__("config_webrx") pm = PropertyManager.getSharedInstance() for name, value in cfg.__dict__.items(): if (name.startswith("__")): continue pm.getProperty(name).setValue(value) + try: + FeatureDetector().detectAllFeatures() + + except RequirementMissingException as e: + print("you are missing required dependencies to run openwebrx. " + "please check the message and the readme for details:") + print(e) + return + RtlNmuxSource() server = ThreadedHttpServer(('0.0.0.0', pm.getPropertyValue("web_port")), RequestHandler) server.serve_forever() + if __name__=="__main__": main()