colosseum-near-rt-ric/setup/sample-xapp/run_xapp.py

32 lines
927 B
Python
Raw Normal View History

2021-12-08 21:17:46 +01:00
import logging
from xapp_control import *
def main():
# configure logger and console output
logging.basicConfig(level=logging.DEBUG, filename='/home/xapp-logger.log', filemode='a+',
format='%(asctime)-15s %(levelname)-8s %(message)s')
formatter = logging.Formatter('%(asctime)-15s %(levelname)-8s %(message)s')
console = logging.StreamHandler()
console.setLevel(logging.INFO)
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)
control_sck = open_control_socket(4200)
while True:
data_sck = receive_from_socket(control_sck)
if len(data_sck) <= 0:
if len(data_sck) == 0:
continue
else:
logging.info('Negative value for socket')
break
else:
logging.info('Received data: ' + repr(data_sck))
if __name__ == '__main__':
main()