Python Shell to msg payload or Python Function


I guess this could be considered a dashboard question even though it centers more around the python shell and python function. Just to give you an idea of what i am trying to do, i am trying to run the Pylogix script module and transfer that data to function so i can use it as a msg.payload for the bar graphs and other things on the dashboard. i am pretty new to python and if anyone has a good place to point me in the right direction i would be very appreciative.



You can also just use the exec node or daemon node to call out to your script… If your script already runs fine from the command line then this is often the easiest way to get something going. If you call it and it returns a result (or stream of results) then ends - use the exec node. If it’s a long running program that you start once in the background and then you need to send it things and get answers back - use the daemon node.

If using the exec node with python also add the -u parameter so the output is unbuffered and you get results as soon as they get sent. eg python -u



Ok I got that one going. If it is a long script in the exec mode with multiple outputs how would I separate those outputs to put in individual output modes or should I run individual script for each output mode I need?



Hi, not sure quite what you mean there. If the script takes a while to run and sends several lines (but does eventually finish) then set the exec node into spawn mode - and it send it’s output a line at a time.
or is that not what you mean ?



When I did this it ended up sending both rows of data to both dashboard modes so I guess I am saying how do i distinguish that line of data from the other line so i can send it to two dashboard modes simultaneously



No idea… it’s your script :slight_smile: maybe put line numbers on ? or some word that is different between each etc that you can use the switch in a following node ?