openwebrx-clone/owrx/__main__.py

75 lines
2.2 KiB
Python
Raw Normal View History

2019-12-08 16:15:48 +00:00
from http.server import HTTPServer
from owrx.http import RequestHandler
from owrx.config import Config
2019-12-08 16:15:48 +00:00
from owrx.feature import FeatureDetector
from owrx.sdr import SdrService
2019-12-08 16:15:48 +00:00
from socketserver import ThreadingMixIn
from owrx.sdrhu import SdrHuUpdater
from owrx.service import Services
from owrx.websocket import WebSocketConnection
from owrx.pskreporter import PskReporter
2020-03-15 22:34:44 +00:00
from owrx.version import openwebrx_version
2019-12-08 16:15:48 +00:00
import logging
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
logger = logging.getLogger(__name__)
2019-12-08 16:15:48 +00:00
class ThreadedHttpServer(ThreadingMixIn, HTTPServer):
pass
def main():
print(
"""
OpenWebRX - Open Source SDR Web App for Everyone! | for license see LICENSE file in the package
_________________________________________________________________________________________________
Author contact info: Jakob Ketterl, DD5JFK <dd5jfk@darc.de>
2020-03-15 22:39:38 +00:00
Documentation: https://github.com/jketterl/openwebrx/wiki
Support and info: https://groups.io/g/openwebrx
2019-12-08 16:15:48 +00:00
"""
)
2020-03-15 22:34:44 +00:00
logger.info("OpenWebRX version {0} starting up...".format(openwebrx_version))
pm = Config.get()
2019-12-08 16:15:48 +00:00
configErrors = Config.validateConfig()
if configErrors:
logger.error(
"your configuration contains errors. please address the following errors:"
)
for e in configErrors:
logger.error(e)
return
2019-12-08 16:15:48 +00:00
featureDetector = FeatureDetector()
if not featureDetector.is_available("core"):
logger.error(
2019-12-08 16:15:48 +00:00
"you are missing required dependencies to run openwebrx. "
"please check that the following core requirements are installed:"
)
logger.error(", ".join(featureDetector.get_requirements("core")))
2019-12-08 16:15:48 +00:00
return
# 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()
Services.start()
try:
2020-03-23 21:09:26 +00:00
server = ThreadedHttpServer(("0.0.0.0", pm["web_port"]), RequestHandler)
2019-12-08 16:15:48 +00:00
server.serve_forever()
except KeyboardInterrupt:
WebSocketConnection.closeAll()
Services.stop()
PskReporter.stop()