Search code examples
pythonwindowswindows-servicesteststand

How to use python to run a teststand sequence


I have a python script that is running as a windows service. It automatically downloads the latest code to my hardware. I'd also like to then test the hardware using "Teststand scripts" automatically.

How do I get my python script to run a Teststand sequence and then email me the results automatically; preferably without even opening the gui?

If I just call the Teststand file from the command prompt it opens the gui, asks for my login, and I still have to press run. I need this to all be handled behind the scenes.


Solution

  • You can do this via the command prompt. So if you want to call it from python use the subprocess module.

    import os                       
    import subprocess
    
    os.chdir("C:\Program Files (x86)\National Instruments\TestStand 2013\Bin") 
    subprocess.Popen(['SeqEdit.exe', '/runEntryPoint', 'Single Pass',...
    'C:\\pathtofile\\myteststandfile.seq', '/quit'])
    

    The key here is the arguments. '/runEntryPoint' and 'Single Pass' force it to run the file on it's own. '/quit' obviously shuts it down once it's finished. If there is nothing that holds up your test, this will launch teststand, run tests, save reports, and close the teststand on its own.