2019-07-21 18:19:33 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2019-05-11 10:58:09 +00:00
|
|
|
from http.server import HTTPServer
|
|
|
|
from owrx.http import RequestHandler
|
2019-05-12 13:56:18 +00:00
|
|
|
from owrx.config import PropertyManager
|
2019-07-21 17:40:28 +00:00
|
|
|
from owrx.feature import FeatureDetector
|
2019-09-22 10:57:13 +00:00
|
|
|
from owrx.source import SdrService
|
2019-05-11 10:58:09 +00:00
|
|
|
from socketserver import ThreadingMixIn
|
2019-05-12 12:35:25 +00:00
|
|
|
from owrx.sdrhu import SdrHuUpdater
|
2019-09-15 19:10:30 +00:00
|
|
|
from owrx.service import Services
|
2019-09-22 10:57:13 +00:00
|
|
|
from owrx.websocket import WebSocketConnection
|
2014-11-29 00:07:10 +00:00
|
|
|
|
2019-05-11 10:58:09 +00:00
|
|
|
import logging
|
2019-07-21 17:40:28 +00:00
|
|
|
|
|
|
|
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():
|
2019-07-21 17:40:28 +00:00
|
|
|
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
|
|
|
|
_________________________________________________________________________________________________
|
|
|
|
|
|
|
|
Author contact info: Andras Retzler, HA7ILM <randras@sdr.hu>
|
|
|
|
|
2019-07-21 17:40:28 +00:00
|
|
|
"""
|
|
|
|
)
|
2019-05-11 10:58:09 +00:00
|
|
|
|
2019-05-12 12:35:25 +00:00
|
|
|
pm = PropertyManager.getSharedInstance().loadConfig("config_webrx")
|
2015-08-17 18:32:58 +00:00
|
|
|
|
2019-05-11 10:58:09 +00:00
|
|
|
featureDetector = FeatureDetector()
|
|
|
|
if not featureDetector.is_available("core"):
|
2019-07-21 17:40:28 +00:00
|
|
|
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()
|
2015-08-17 18:32:58 +00:00
|
|
|
|
2019-05-12 12:35:25 +00:00
|
|
|
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
|
|
|
|
2019-07-21 17:40:28 +00:00
|
|
|
server = ThreadedHttpServer(("0.0.0.0", pm.getPropertyValue("web_port")), RequestHandler)
|
2019-05-11 10:58:09 +00:00
|
|
|
server.serve_forever()
|
2015-08-17 18:32:58 +00:00
|
|
|
|
|
|
|
|
2019-05-11 10:58:09 +00:00
|
|
|
if __name__ == "__main__":
|
2019-05-12 16:10:24 +00:00
|
|
|
try:
|
|
|
|
main()
|
|
|
|
except KeyboardInterrupt:
|
2019-09-22 10:57:13 +00:00
|
|
|
WebSocketConnection.closeAll()
|
2019-10-27 11:16:17 +00:00
|
|
|
Services.stop()
|