openwebrx-clone/server.py

43 lines
1.5 KiB
Python
Raw Normal View History

2019-05-03 20:59:24 +00:00
from http.server import HTTPServer
from owrx.http import RequestHandler
2019-05-05 17:59:03 +00:00
from owrx.config import PropertyManager, FeatureDetector, RequirementMissingException
2019-05-09 20:44:29 +00:00
from owrx.source import SdrService
2019-05-04 18:26:11 +00:00
from socketserver import ThreadingMixIn
2019-05-04 14:56:23 +00:00
2019-05-10 19:50:58 +00:00
import logging
logging.basicConfig(level = logging.DEBUG, format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s")
2019-05-04 18:26:11 +00:00
class ThreadedHttpServer(ThreadingMixIn, HTTPServer):
pass
2019-05-03 20:59:24 +00:00
2019-05-04 18:26:11 +00:00
def main():
2019-05-05 17:59:03 +00:00
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()
2019-05-04 18:26:11 +00:00
cfg=__import__("config_webrx")
pm = PropertyManager.getSharedInstance()
for name, value in cfg.__dict__.items():
if (name.startswith("__")): continue
2019-05-09 20:44:29 +00:00
pm[name] = value
2019-05-03 20:59:24 +00:00
2019-05-07 13:50:20 +00:00
featureDetector = FeatureDetector()
if not featureDetector.is_available("core"):
2019-05-05 17:59:03 +00:00
print("you are missing required dependencies to run openwebrx. "
2019-05-07 13:50:20 +00:00
"please check that the following core requirements are installed:")
print(", ".join(featureDetector.get_requirements("core")))
2019-05-05 17:59:03 +00:00
return
# Get error messages about unknown / unavailable features as soon as possible
SdrService.loadProps()
2019-05-05 13:53:35 +00:00
server = ThreadedHttpServer(('0.0.0.0', pm.getPropertyValue("web_port")), RequestHandler)
2019-05-04 18:26:11 +00:00
server.serve_forever()
2019-05-05 17:59:03 +00:00
2019-05-04 18:26:11 +00:00
if __name__=="__main__":
main()