X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=examples%2Fping_xapp.py;h=c247ee30d5a639c19164718ef74e44869ca00750;hb=bbc9028aa34ae48e7806596cd05fbe7a5bfd7fb8;hp=145dd5b60d7c8922607aa8910d7a2f0514e5aa28;hpb=f9cd5cc676355485c2d9c8bc2be22ddad4874382;p=ric-plt%2Fxapp-frame-py.git diff --git a/examples/ping_xapp.py b/examples/ping_xapp.py index 145dd5b..c247ee3 100644 --- a/examples/ping_xapp.py +++ b/examples/ping_xapp.py @@ -29,10 +29,10 @@ def entry(self): number = 0 while True: # test healthcheck - print("Healthy? {}".format(xapp.healthcheck())) + print("ping is healthy? {}".format(xapp.healthcheck())) # rmr send to default handler - self.rmr_send(json.dumps({"sup": number}).encode(), 6660666) + self.rmr_send(json.dumps({"ping": number}).encode(), 6660666) # rmr send 60000, should trigger registered callback val = json.dumps({"test_send": number}).encode() @@ -40,14 +40,19 @@ def entry(self): number += 1 # store it in SDL and read it back; delete and read - self.sdl_set(my_ns, "numba", number) - print((self.sdl_get(my_ns, "numba"), self.sdl_find_and_get(my_ns, "num"))) - self.sdl_delete(my_ns, "numba") - print(self.sdl_get(my_ns, "numba")) + self.sdl_set(my_ns, "ping", number) + self.logger.info(self.sdl_get(my_ns, "ping")) + self.logger.info(self.sdl_find_and_get(my_ns, "pin")) + self.sdl_delete(my_ns, "ping") + self.logger.info(self.sdl_get(my_ns, "ping")) # rmr receive for (summary, sbuf) in self.rmr_get_messages(): - print(summary) + # summary is a dict that contains bytes so we can't use json.dumps on it + # so we have no good way to turn this into a string to use the logger unfortunately + # print is more "verbose" than the ric logger + # if you try to log this you will get: TypeError: Object of type bytes is not JSON serializable + print("ping: {0}".format(summary)) self.rmr_free(sbuf) time.sleep(2)