openwebrx-clone/openwebrx.py

67 lines
1.9 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
2019-05-11 10:58:09 +00:00
from http.server import HTTPServer
from owrx.http import RequestHandler
from owrx.config import PropertyManager
from owrx.feature import FeatureDetector
from owrx.source import SdrService
2019-05-11 10:58:09 +00:00
from socketserver import ThreadingMixIn
from owrx.sdrhu import SdrHuUpdater
2019-09-15 19:10:30 +00:00
from owrx.service import Services
from owrx.websocket import WebSocketConnection
from owrx.pskreporter import PskReporter
2014-11-29 00:07:10 +00:00
2019-05-11 10:58:09 +00:00
import logging
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
2014-11-29 00:07:10 +00:00
2019-05-11 10:58:09 +00:00
class ThreadedHttpServer(ThreadingMixIn, HTTPServer):
2016-03-20 15:06:10 +00:00
pass
2014-11-29 00:07:10 +00:00
2015-09-30 14:06:30 +00:00
2014-11-29 00:07:10 +00:00
def main():
print(
"""
2019-05-11 11:25:48 +00:00
OpenWebRX - Open Source SDR Web App for Everyone! | for license see LICENSE file in the package
_________________________________________________________________________________________________
2019-11-24 17:08:54 +00:00
Author contact info: Andras Retzler, HA7ILM <randras@sdr.hu>
2019-11-12 12:43:39 +00:00
Author contact info: Jakob Ketterl, DD5JFK <dd5jfk@darc.de>
2019-05-11 11:25:48 +00:00
"""
)
2019-05-11 10:58:09 +00:00
pm = PropertyManager.getSharedInstance().loadConfig("config_webrx")
2019-05-11 10:58:09 +00:00
featureDetector = FeatureDetector()
if not featureDetector.is_available("core"):
print(
"you are missing required dependencies to run openwebrx. "
"please check that the following core requirements are installed:"
)
2019-05-11 10:58:09 +00:00
print(", ".join(featureDetector.get_requirements("core")))
return
2014-11-29 00:07:10 +00:00
2019-05-11 10:58:09 +00:00
# Get error messages about unknown / unavailable features as soon as possible
SdrService.loadProps()
if "sdrhu_key" in pm and pm["sdrhu_public_listing"]:
updater = SdrHuUpdater()
updater.start()
2019-09-15 19:10:30 +00:00
Services.start()
2019-07-21 21:39:11 +00:00
server = ThreadedHttpServer(("0.0.0.0", pm.getPropertyValue("web_port")), RequestHandler)
2019-05-11 10:58:09 +00:00
server.serve_forever()
2019-05-11 10:58:09 +00:00
if __name__ == "__main__":
2019-05-12 16:10:24 +00:00
try:
main()
except KeyboardInterrupt:
WebSocketConnection.closeAll()
2019-10-27 11:16:17 +00:00
Services.stop()
PskReporter.stop()