简体   繁体   English

来自python脚本的TFS CLI命令

[英]TFS CLI commands from python script

I am writing some python extension scripts to integrate TFS version control functionality to our tool. 我正在编写一些python扩展脚本,以将TFS版本控制功能集成到我们的工具中。 The process that we follow is something like this, 我们遵循的过程是这样的,

1, The TFS.exe cli commands are written to a batch file. 1,将TFS.exe cli命令写入批处理文件。 2, The batch file is executed using python subprocess.call(batch_file, shell=True) 2,使用python subprocess.call(batch_file,shell = True)执行批处理文件

The issue that I have is that, these dialog does not come up when the batch files are run from python. 我的问题是,当从python运行批处理文件时,这些对话框没有出现。 I just tested the cli commands by running the commands from the batch file in command prompt and they do bring up the expected dialog (eg - create / edit work-spaces etc.). 我只是通过在命令提示符下运行批处理文件中的命令来测试cli命令,它们确实会弹出预期的对话框(例如-创建/编辑工作区等)。

Can somebody shed some light? 有人可以照亮吗? Am I doing anything wrong, or am I missing something while invoking tf.exe (I don't have the /noprompt switch in any of my commands). 我是在做错什么,还是在调用tf.exe时缺少了什么(我的任何命令中都没有/ noprompt开关)。 The return code is 100 which implies nothing succeeded. 返回码为100,表示没有成功。 The interesting part is the same command succeeds when I run it in command prompt, the command prompt by default runs the CLI commands under %USERPROFILE% directory. 有趣的是,当我在命令提示符下运行该命令时,该命令也会成功执行,该命令提示符默认情况下在%USERPROFILE%目录下运行CLI命令。

If I try executing some dummy TortoiseSVN cli commands from the batch file in the same manner they do bring up the respective TortoiseSvn dialog. 如果我尝试以相同的方式从批处理文件中执行一些虚拟的TortoiseSVN cli命令,它们会弹出相应的TortoiseSvn对话框。 So I assume its not a problem with the batch file executing from Python. 因此,我认为从Python执行批处理文件不是问题。

Could it be a problem with the user rights..? 可能是用户权限问题。

Thanks and Regards, Joe. 谢谢,问候,乔。

I use "os.system" to call the bat file, it works. 我使用“ os.system”来调用bat文件,它可以工作。

import os
os.system("c:\\xxx.bat")

Code in bat file: bat文件中的代码:

cd C:\Users\XXX\Source\Workspaces\XXX\XXX
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\tf.exe" view *.cs
pause

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

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