add feature detection
This commit is contained in:
parent
142a4c87bd
commit
30f8244abf
@ -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\"!")
|
||||
|
21
server.py
21
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 <randras@sdr.hu>")
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user