openwebrx-clone/openwebrx.py

53 lines
1.6 KiB
Python
Raw Normal View History

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
2019-05-12 16:10:24 +00:00
from owrx.source import SdrService, ClientRegistry
2019-05-11 10:58:09 +00:00
from socketserver import ThreadingMixIn
from owrx.sdrhu import SdrHuUpdater
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():
2019-05-11 11:25:48 +00:00
print("""
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-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:")
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-05-11 10:58:09 +00:00
server = ThreadedHttpServer(('0.0.0.0', pm.getPropertyValue("web_port")), RequestHandler)
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:
for c in ClientRegistry.getSharedInstance().clients:
c.close()