1 # ==================================================================================
3 # Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 # ==================================================================================
20 from ricxappframe.xapp_frame import RMRXapp, rmr
21 from ricxappframe.alarm import alarm
24 # pylint: disable=invalid-name
30 Function that runs when xapp initialization is complete
32 self.logger.info("post_init called")
34 def handle_config_change(self, config):
36 Function that runs at start and on every configuration file change.
38 self.logger.info("handle_config_change: config: {}".format(config))
41 def default_handler(self, summary, sbuf):
43 Function that processes messages for which no handler is defined
45 self.logger.info("default_handler called")
49 def start(thread=False):
51 This is a convenience function that allows this xapp to run in Docker
52 for "real" (no thread, real SDL), but also easily modified for unit testing
53 (e.g., use_fake_sdl). The defaults for this function are for the Dockerized xapp.
56 fake_sdl = getenv("USE_FAKE_SDL", True)
57 config_file = getenv("CONFIG_FILE", None)
58 rmr_xapp = RMRXapp(default_handler,
59 config_handler=handle_config_change,
62 use_fake_sdl=bool(fake_sdl))
68 can only be called if thread=True when started
69 TODO: could we register a signal handler for Docker SIGTERM that calls this?
73 if __name__ == "__main__":