X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain.py;h=34875b3248b59d5ee19112403b853a3f5bfaa88c;hb=HEAD;hp=10ad0f8a66e39a5c0caf22cdb9ad9f6ef41dc32d;hpb=8721b01163df82a68fdfe5ea9b8722b533e10779;p=ric-app%2Fhw-python.git diff --git a/src/main.py b/src/main.py index 10ad0f8..34875b3 100644 --- a/src/main.py +++ b/src/main.py @@ -13,62 +13,16 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +# # ================================================================================== -import json -from os import getenv -from ricxappframe.xapp_frame import RMRXapp, rmr -from ricxappframe.alarm import alarm - - -# pylint: disable=invalid-name -rmr_xapp = None - - -def post_init(self): - """ - Function that runs when xapp initialization is complete - """ - self.logger.info("post_init called") - -def handle_config_change(self, config): - """ - Function that runs at start and on every configuration file change. - """ - self.logger.info("handle_config_change: config: {}".format(config)) - - -def default_handler(self, summary, sbuf): - """ - Function that processes messages for which no handler is defined - """ - self.logger.info("default_handler called") - self.rmr_free(sbuf) - +from .hwxapp import HWXapp -def start(thread=False): - """ - This is a convenience function that allows this xapp to run in Docker - for "real" (no thread, real SDL), but also easily modified for unit testing - (e.g., use_fake_sdl). The defaults for this function are for the Dockerized xapp. - """ - global rmr_xapp - fake_sdl = getenv("USE_FAKE_SDL", True) - config_file = getenv("CONFIG_FILE", None) - rmr_xapp = RMRXapp(default_handler, - config_handler=handle_config_change, - rmr_port=4560, - post_init=post_init, - use_fake_sdl=bool(fake_sdl)) - rmr_xapp.run(thread) +def launchXapp(): + hwxapp = HWXapp() + hwxapp.start() -def stop(): - """ - can only be called if thread=True when started - TODO: could we register a signal handler for Docker SIGTERM that calls this? - """ - rmr_xapp.stop() if __name__ == "__main__": - start() + launchXapp()