restructure project for packaging
This commit is contained in:
		
							
								
								
									
										1
									
								
								debian/openwebrx.install
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								debian/openwebrx.install
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| config_webrx.py etc/ | ||||
							
								
								
									
										64
									
								
								openwebrx.py
									
									
									
									
									
								
							
							
						
						
									
										64
									
								
								openwebrx.py
									
									
									
									
									
								
							| @@ -1,66 +1,6 @@ | ||||
| #!/usr/bin/env python3 | ||||
|  | ||||
| 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 | ||||
| from socketserver import ThreadingMixIn | ||||
| from owrx.sdrhu import SdrHuUpdater | ||||
| from owrx.service import Services | ||||
| from owrx.websocket import WebSocketConnection | ||||
| from owrx.pskreporter import PskReporter | ||||
|  | ||||
| import logging | ||||
|  | ||||
| logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s") | ||||
|  | ||||
|  | ||||
| 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:    Andras Retzler, HA7ILM <randras@sdr.hu> | ||||
| Author contact info:    Jakob Ketterl, DD5JFK <dd5jfk@darc.de> | ||||
|  | ||||
|     """ | ||||
|     ) | ||||
|  | ||||
|     pm = PropertyManager.getSharedInstance().loadConfig("config_webrx") | ||||
|  | ||||
|     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 | ||||
|  | ||||
|     # 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() | ||||
|  | ||||
|     server = ThreadedHttpServer(("0.0.0.0", pm.getPropertyValue("web_port")), RequestHandler) | ||||
|     server.serve_forever() | ||||
|  | ||||
| from owrx.__main__ import main | ||||
|  | ||||
| if __name__ == "__main__": | ||||
|     try: | ||||
|         main() | ||||
|     except KeyboardInterrupt: | ||||
|         WebSocketConnection.closeAll() | ||||
|         Services.stop() | ||||
|         PskReporter.stop() | ||||
|     main() | ||||
|   | ||||
							
								
								
									
										60
									
								
								owrx/__main__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								owrx/__main__.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,60 @@ | ||||
| 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 | ||||
| from socketserver import ThreadingMixIn | ||||
| from owrx.sdrhu import SdrHuUpdater | ||||
| from owrx.service import Services | ||||
| from owrx.websocket import WebSocketConnection | ||||
| from owrx.pskreporter import PskReporter | ||||
|  | ||||
| import logging | ||||
|  | ||||
| logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s") | ||||
|  | ||||
|  | ||||
| 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:    Andras Retzler, HA7ILM <randras@sdr.hu> | ||||
| Author contact info:    Jakob Ketterl, DD5JFK <dd5jfk@darc.de> | ||||
|  | ||||
|     """ | ||||
|     ) | ||||
|  | ||||
|     pm = PropertyManager.getSharedInstance().loadConfig() | ||||
|  | ||||
|     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 | ||||
|  | ||||
|     # 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: | ||||
|         server = ThreadedHttpServer(("0.0.0.0", pm.getPropertyValue("web_port")), RequestHandler) | ||||
|         server.serve_forever() | ||||
|     except KeyboardInterrupt: | ||||
|         WebSocketConnection.closeAll() | ||||
|         Services.stop() | ||||
|         PskReporter.stop() | ||||
| @@ -1,3 +1,4 @@ | ||||
| import importlib.util | ||||
| import logging | ||||
|  | ||||
| logger = logging.getLogger(__name__) | ||||
| @@ -50,6 +51,10 @@ class Property(object): | ||||
|         return self | ||||
|  | ||||
|  | ||||
| class ConfigNotFoundException(Exception): | ||||
|     pass | ||||
|  | ||||
|  | ||||
| class PropertyManager(object): | ||||
|     sharedInstance = None | ||||
|  | ||||
| @@ -128,10 +133,17 @@ class PropertyManager(object): | ||||
|                 p.setValue(other_pm[key]) | ||||
|         return self | ||||
|  | ||||
|     def loadConfig(self, filename): | ||||
|         cfg = __import__(filename) | ||||
|         for name, value in cfg.__dict__.items(): | ||||
|             if name.startswith("__"): | ||||
|                 continue | ||||
|             self[name] = value | ||||
|         return self | ||||
|     def loadConfig(self): | ||||
|         for file in ["/etc/config_webrx.py", "./config_webrx.py"]: | ||||
|             try: | ||||
|                 spec = importlib.util.spec_from_file_location("config_webrx", file) | ||||
|                 cfg = importlib.util.module_from_spec(spec) | ||||
|                 spec.loader.exec_module(cfg) | ||||
|                 for name, value in cfg.__dict__.items(): | ||||
|                     if name.startswith("__"): | ||||
|                         continue | ||||
|                     self[name] = value | ||||
|                 return self | ||||
|             except FileNotFoundError: | ||||
|                 logger.debug("not found: %s", file) | ||||
|         raise ConfigNotFoundException("no usable config found! please make sure you have a valid configuration file!") | ||||
|   | ||||
| @@ -3,7 +3,7 @@ from owrx.socket import getAvailablePort | ||||
| from datetime import datetime, timezone, timedelta | ||||
| from owrx.source import SdrService, SdrSource | ||||
| from owrx.bands import Bandplan | ||||
| from csdr import dsp, output | ||||
| from csdr.csdr import dsp, output | ||||
| from owrx.wsjt import WsjtParser | ||||
| from owrx.aprs import AprsParser | ||||
| from owrx.config import PropertyManager | ||||
|   | ||||
| @@ -7,7 +7,7 @@ from owrx.aprs import AprsParser | ||||
| from owrx.metrics import Metrics, DirectMetric | ||||
| from owrx.socket import getAvailablePort | ||||
| import threading | ||||
| import csdr | ||||
| from csdr import csdr | ||||
| import time | ||||
| import os | ||||
| import signal | ||||
|   | ||||
							
								
								
									
										2
									
								
								sdrhu.py
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								sdrhu.py
									
									
									
									
									
								
							| @@ -25,7 +25,7 @@ from owrx.sdrhu import SdrHuUpdater | ||||
| from owrx.config import PropertyManager | ||||
|  | ||||
| if __name__ == "__main__": | ||||
|     pm = PropertyManager.getSharedInstance().loadConfig("config_webrx") | ||||
|     pm = PropertyManager.getSharedInstance().loadConfig() | ||||
|  | ||||
|     if not "sdrhu_key" in pm: | ||||
|         exit(1) | ||||
|   | ||||
							
								
								
									
										10
									
								
								setup.py
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								setup.py
									
									
									
									
									
								
							| @@ -1,11 +1,14 @@ | ||||
| from setuptools import setup, find_packages | ||||
| from setuptools import setup, find_namespace_packages | ||||
| from owrx.version import strictversion | ||||
|  | ||||
| setup( | ||||
|     name="OpenWebRX", | ||||
|     version=str(strictversion), | ||||
|     packages=find_packages(), | ||||
|     entry_points={"console_scripts": ["openwebrx=openwebrx:main"]}, | ||||
|     packages=find_namespace_packages(include=["owrx", "csdr", "htdocs"]), | ||||
|     package_data={ | ||||
|         "htdocs": ["*", "**/*"] | ||||
|     }, | ||||
|     entry_points={"console_scripts": ["openwebrx=owrx.__main__:main"]}, | ||||
|     # use the github page for now | ||||
|     url="https://github.com/jketterl/openwebrx", | ||||
|     author="András Retzler, Jakob Ketterl", | ||||
| @@ -13,4 +16,5 @@ setup( | ||||
|     maintainer="Jakob Ketterl", | ||||
|     maintainer_email="jakob.ketterl@gmx.de", | ||||
|     license="GAGPL", | ||||
|     python_requires=">=3.6", | ||||
| ) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jakob Ketterl
					Jakob Ketterl