Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to trigger #12

Open
chrisegge opened this issue May 3, 2019 · 13 comments
Open

How to trigger #12

chrisegge opened this issue May 3, 2019 · 13 comments

Comments

@chrisegge
Copy link

How do you trigger the node to start running automatically

@namgk
Copy link
Owner

namgk commented May 3, 2019 via email

@chrisegge
Copy link
Author

Yea I had the continuous checked so it wouldn't let me. What about the output? Instead of individual outputs like a function node running it's an ever growing array of data. Is this normal?

@namgk
Copy link
Owner

namgk commented May 5, 2019 via email

@DotoPototo
Copy link

When ticking the 'continuous' option, you can no longer inject into the pythonshell node. This means I can't get the pythonshell node to start on startup

@namgk
Copy link
Owner

namgk commented Nov 5, 2019

As I remember, it starts when it gets the first message. Can you double check?

@DotoPototo
Copy link

I tried but it did not work. The only way I can get it working is to manually start it.

@ozett
Copy link

ozett commented Jul 27, 2020

yeah, still buggy... cant check "continous" or "std-in" separately.... hope the update is integrated soon -> #15 (comment)

@BigJerBD
Copy link
Collaborator

BigJerBD commented Jul 28, 2020

@ozett the node , when continuous is true , by default receives input with stdin. This is why once you set have continuous to True you cannot check the stdin button anymore. It is also because a continuous that does not recieve any input does not make a lot of sense .

A process that have stdIn to true without being continuous will be run once when a payload is recieved. If you send an other payload, it will not trigger another time, I rarely use in and just use continuous instead most of the time :

  • If I want python to use the same process I just use a while loop in my python code get the inputs
  • if not , once the python process is over you can still send an other payload to the node, it will start another process.

Would you mind explaining your use case? Maybe I could recommend you the proper way to run your node depending on your answer

@ozett
Copy link

ozett commented Jul 28, 2020

my use case:
my camera at the front door triggers internally motion-detection, i pass this motion-alert to mqtt in node-red, grab an image and feed this image into an python script for face-detection.

to be a little flexible i wanted to pass some parameters via std-in from node-red to the python script.
i thought i have to check the box named "std-in" to pass my args to the script.
but that did not worked.

i only wanted to trigger the script once for every image, but i sounds a cool option to let it run contiunously.
i dont see clearly how to configure this. but could be cool maybe to feed a video-sequence to the script.

image

@ozett
Copy link

ozett commented Jul 28, 2020

i assumed that i had to check th "std-in" box, to send my args via std-in from node-red to the script.
but std-in alone is not checkable...
(i am also not sure if the virtual-path is correct and works as i expect.
normally i switched to the virtual-env on the cmd-line with: "workon virtname"...

pynode

@BigJerBD
Copy link
Collaborator

In your situation I think setting continuous and stdin to True will work. The word continuous does not mean that the script is alway running, but only that the node can receive a stream of input

I have similar use case when instead of image input , i have text data that needs a python trigger .
I those cases I set both to true and in my code I call the input() python function to get the data from stdin

the node will then :

  • receive the payload
  • start the python script (without any argument )
  • pipe the payload into the process (thats why you need input() in your code
  • process ends

if an other image is received it should do the same thing again and again

@ozett
Copy link

ozett commented Jul 29, 2020

i will give it a try.
any idea how to activate my virtual environment from the node?
i normally use workon to activate -> https://virtualenvwrapper.readthedocs.io/en/latest/command_ref.html#workon

@ozett
Copy link

ozett commented Jul 29, 2020

found some hints to "activate" virt-envs while using python3 directly from the path of the virt-env.
https://stackoverflow.com/a/26172104

what is the way with this pythonshell-node? any example available? thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants