python-opcua icon indicating copy to clipboard operation
python-opcua copied to clipboard

Prevent auto printed messages upon connection

Open AndrewStuhr opened this issue 3 years ago • 6 comments

Hello

I'm seeing the following 3 lines printed after making an OPC connection:

Screenshot (12)

Is there a way I can stop these from printing?

Thanks!

AndrewStuhr avatar Sep 09 '20 01:09 AndrewStuhr

these messages came from a logger! just for my understanding why do you want to achieve this? sounds like you want to use "stdout" for something?

the thing is if you remove or overwrite the logger nothing gets logged anymore, the other way would be to make a virtual environment with a local version of python-opcua and comment these 3 lines out (if you just want to remove only these particular lines)

AndreasHeine avatar Sep 09 '20 06:09 AndreasHeine

That realy looks like a logger message and I guess it is the one in ua_client.py in create_session() (no warrent).

Additionally to @AndreasHeine you may set the logger level to warning (but be aware that all debugging and info logs won't appear anymore, just warning- and error logs!), depending on your codecontext.

swamper123 avatar Sep 09 '20 08:09 swamper123

Thanks guys! I'm using print() to pass data back to a webpage. The logging messages are nice, but giving me trouble with the return data format. I'll try changing the warning level, and if that doesn't work, commenting out the lines.

AndrewStuhr avatar Sep 09 '20 15:09 AndrewStuhr

Not sure what you are doing, but using print() as output to a web server or something is probably not a good design.

zerox1212 avatar Sep 09 '20 16:09 zerox1212

sounds like node-red pythonshell node 🤔 have you tought about using a websocket to pass data to the webpage?

https://github.com/AndreasHeine/opcua-sub-to-websocket

AndreasHeine avatar Sep 09 '20 16:09 AndreasHeine

Good to know guys. I'm using IIS, calling python scripts with AJAX, and returning data with print(). I'm planning to switch to Flask at some point. Thanks for the websockets idea, I'll look into that. I'd love to hear any other ideas!

AndrewStuhr avatar Sep 09 '20 16:09 AndrewStuhr