简体   繁体   English

如何使用python运行测试台序列

[英]How to use python to run a teststand sequence

I have a python script that is running as a windows service. 我有一个作为Windows服务运行的python脚本。 It automatically downloads the latest code to my hardware. 它会自动将最新代码下载到我的硬件上。 I'd also like to then test the hardware using "Teststand scripts" automatically. 我还想使用“ Teststand脚本”自动测试硬件。

How do I get my python script to run a Teststand sequence and then email me the results automatically; 如何获取我的python脚本以运行Teststand序列,然后自动将结果通过电子邮件发送给我; preferably without even opening the gui? 最好甚至不用打开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. 如果仅从命令提示符下调用Teststand文件,它将打开gui,要求我登录,而我仍然必须按run。 I need this to all be handled behind the scenes. 我需要在后台处理所有这些。

You can do this via the command prompt. 您可以通过命令提示符执行此操作。 So if you want to call it from python use the subprocess module. 因此,如果要从python调用它,请使用subprocess模块​​。

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. '/ runEntryPoint'和'Single Pass'强制它自己运行文件。 '/quit' obviously shuts it down once it's finished. 一旦完成,“ / quit”显然会将其关闭。 If there is nothing that holds up your test, this will launch teststand, run tests, save reports, and close the teststand on its own. 如果没有任何东西可以阻止您的测试,这将启动测试台,运行测试,保存报告并自行关闭测试台。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM