Commit 95ae2e1b authored by Ivan Tyagov's avatar Ivan Tyagov

WIP

parent 89886652
...@@ -12,10 +12,11 @@ import requests ...@@ -12,10 +12,11 @@ import requests
import urllib import urllib
import argparse import argparse
import logging import logging
import __main__
# ################################# # #################################
# Configure # Configure
# XXX: addn erp5_username and erp5_password!
parser = argparse.ArgumentParser(description='Run OPCUA Server.') parser = argparse.ArgumentParser(description='Run OPCUA Server.')
a = parser.add_argument a = parser.add_argument
a('--ip', help='The IP address on which the OPCUA Server runs', default="127.0.0.1") a('--ip', help='The IP address on which the OPCUA Server runs', default="127.0.0.1")
...@@ -64,6 +65,7 @@ if erp5_ip is not None and erp5_port is not None: ...@@ -64,6 +65,7 @@ if erp5_ip is not None and erp5_port is not None:
# Start OPCUA Server # Start OPCUA Server
async def main(): async def main():
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
# setup our server # setup our server
server = asyncua.Server() server = asyncua.Server()
await server.init() await server.init()
...@@ -87,14 +89,13 @@ async def main(): ...@@ -87,14 +89,13 @@ async def main():
server.iserver.create_session = create_session server.iserver.create_session = create_session
_logger.info("Added subscription for erp5 handler.") _logger.info("Added subscription for erp5 handler.")
_logger.info("Starting server!") _logger.info("Starting server!")
async with server: async with server:
while True: while True:
await asyncio.sleep(1) await asyncio.sleep(1)
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.INFO)
asyncio.run(main(), debug=True) asyncio.run(main(), debug=True)
import __main__
if __name__ == '__main__': if __name__ == '__main__':
sys.exit(__main__.main()) sys.exit(__main__.main())
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment