Page 1 of 1
How to detect Python execution environment
Posted: Saturday 18 February 2017 11:25
by Number8
Hello,
Is there a way to detect Python scripts execution environment, that is interactive (from a terminal session) or directly from Domoticz
Thank you
Re: How to detect Python execution environment
Posted: Saturday 18 February 2017 15:36
by waaren
@Number8,
do you mean
$which python3.5
/usr/local/bin/python3.5
$which python
/usr/bin/python
$python --version
Python 2.7.12
$python3.5 --version
Python 3.5.1
Re: How to detect Python execution environment
Posted: Saturday 18 February 2017 16:11
by SweetPants
or:
/usr/bin/env python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Re: How to detect Python execution environment
Posted: Tuesday 21 February 2017 6:56
by Number8
Thanks for your replies. However this is not what I'm looking for. Inside a script, I want to detect whether Python has been launched from a terminal session (SSH), that is with direct user interaction, or from a control within Domoticz?
Is there a way to detect that?
Re: How to detect Python execution environment
Posted: Tuesday 21 February 2017 7:59
by EddyG
Shell variable PPID -> parent pid
So 'echo $PPID' gives the parent PID, go from there.
Re: How to detect Python execution environment
Posted: Tuesday 21 February 2017 8:02
by Number8
Thanks EddyG, this is the idea I was looking for.