04-12-2019 09:56 AM
Hi all,
I need to run a python script from a sequence using the python step found here.
My sequence looks like this:
Both TS-DummyGateway.py and TS-OtherDummyGateway.py contain the following code:
import sys import datetime import os def hello(): return "Hello, now is : " + str(datetime.datetime.now()) + "& current dir :" + str(os.getcwd());
The sequence calls both python script and display their return messages.
The python step setup:
Both steps have the same config besides the python file path.
When running the sequence I am expecting the python script to display its current location (ie the location of the .py file), instead of that I am getting the folder where the sequence is located. In order to fix it I just need to config the step and select again the python script that is in the field "file path". When I then run the sequence again I can this time see the proper python script location being displayed on screen.
If I close TestStand and re-open it will misbehave again and I have to do that trick (select the script that is already picked in "file path") to make it work.
Finally, when I fix one of the python steps, both will display the folder of the one that just got fixed, it is not possible for them to display separate folders.
My interpretation: when TestStand is opened it selects by default its surrounding folder as environement, when I select a python script this environement changes to the folder containing the script, and so on for each script changes.
What I would like: for python to run from where it is located.
Has anyone any idea on how to do that? I cannot be the only that has come across this problem.
Thanks in advance for any tip ! 🙂
Attached is the Sequence and both python files, you will need to put them wherever you like in your file system and configure the sequence accordingly.
04-13-2019 10:51 PM
04-18-2019 02:31 AM
Hi Shashidhar,
That's what I tried at first using a hard coded value for the file path but it didn't work, I don't know why.
I then tried what you proposed and it worked perfectly ! Thanks for your help.