extended feature detection
This commit is contained in:
parent
e937f2bca3
commit
df9646aaf9
@ -39,16 +39,37 @@ class RequirementMissingException(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
class FeatureDetector(object):
|
class FeatureDetector(object):
|
||||||
def detectAllFeatures(self):
|
features = {
|
||||||
print("Starting Feature detection")
|
"core": [ "csdr", "nmux" ],
|
||||||
self.detect_csdr()
|
"rtl_sdr": [ "rtl_sdr" ],
|
||||||
self.detect_nmux()
|
"sdrplay": [ "rx_tools" ],
|
||||||
print("Feature detection completed.")
|
"hackrf": [ "rx_tools" ]
|
||||||
|
}
|
||||||
|
|
||||||
def detect_csdr(self):
|
def is_available(self, feature):
|
||||||
if os.system("csdr 2> /dev/null") == 32512: #check for csdr
|
return self.has_requirements(self.get_requirements(feature))
|
||||||
raise RequirementMissingException("You need to install \"csdr\" to run OpenWebRX!")
|
|
||||||
|
|
||||||
def detect_nmux(self):
|
def get_requirements(self, feature):
|
||||||
if os.system("nmux --help 2> /dev/null") == 32512: #check for nmux
|
return FeatureDetector.features[feature]
|
||||||
raise RequirementMissingException("You need to install an up-to-date version of \"csdr\" that contains the \"nmux\" tool to run OpenWebRX! Please upgrade \"csdr\"!")
|
|
||||||
|
def has_requirements(self, requirements):
|
||||||
|
passed = True
|
||||||
|
for requirement in requirements:
|
||||||
|
methodname = "has_" + requirement
|
||||||
|
if hasattr(self, methodname) and callable(getattr(self, methodname)):
|
||||||
|
passed = passed and getattr(self, methodname)()
|
||||||
|
else:
|
||||||
|
print("detection of requirement {0} not implement. please fix in code!".format(requirement))
|
||||||
|
return passed
|
||||||
|
|
||||||
|
def has_csdr(self):
|
||||||
|
return os.system("csdr 2> /dev/null") != 32512
|
||||||
|
|
||||||
|
def has_nmux(self):
|
||||||
|
return os.system("nmux --help 2> /dev/null") != 32512
|
||||||
|
|
||||||
|
def has_rtl_sdr(self):
|
||||||
|
return os.system("rtl_sdr --help 2> /dev/null") != 32512
|
||||||
|
|
||||||
|
def has_rx_tools(self):
|
||||||
|
return os.system("rx_sdr --help 2> /dev/null") != 32512
|
||||||
|
10
server.py
10
server.py
@ -21,13 +21,11 @@ def main():
|
|||||||
if (name.startswith("__")): continue
|
if (name.startswith("__")): continue
|
||||||
pm.getProperty(name).setValue(value)
|
pm.getProperty(name).setValue(value)
|
||||||
|
|
||||||
try:
|
featureDetector = FeatureDetector()
|
||||||
FeatureDetector().detectAllFeatures()
|
if not featureDetector.is_available("core"):
|
||||||
|
|
||||||
except RequirementMissingException as e:
|
|
||||||
print("you are missing required dependencies to run openwebrx. "
|
print("you are missing required dependencies to run openwebrx. "
|
||||||
"please check the message and the readme for details:")
|
"please check that the following core requirements are installed:")
|
||||||
print(e)
|
print(", ".join(featureDetector.get_requirements("core")))
|
||||||
return
|
return
|
||||||
|
|
||||||
if (pm.getPropertyValue("start_rtl_thread")):
|
if (pm.getPropertyValue("start_rtl_thread")):
|
||||||
|
Loading…
Reference in New Issue
Block a user