我正试着给指挥部打电话
& 'C:\Users\USERNAME\AppData\Local\Programs\Microsoft VS Code\bin\code' --folder-uri='vscode-remote://ssh-remote+SERVER.domain.net/home/USERNAME/Dropbox/Projects/PROJECTNAME'
从Python脚本,
codepath = os.path.join(os.environ['LocalAppData'], 'Programs', 'Microsoft VS Code', 'bin', 'code')
path_parts = (
"--folder-uri='vscode-remote://ssh-remote+SERVER.domain.net/home/USERNAME/Dropbox/Projects/PROJECTNAME'",
)
subprocess.call([codepath] + list(path_parts), shell=True)
如果我把第一个命令放到一个交互式的powershell中,vscode就能正常打开(modulo将大写占位符替换为实际存在的东西)。
如果我做
"C:\Users\USERNAME\AppData\Local\Programs\Microsoft VS Code\Code.exe" --folder-uri="vscode-remote://ssh-remote+SERVER.tomsb.net/home/USERNAME/Dropbox/Projects/PROJECTNAME"
在一个交互式的窗口命令提示符,它打开。
然而,python代码只是打开vscode,就好像没有给出参数一样(或者就好像给出了一个混乱的本地路径--我可以通过在第一个call
参数中提供第二个条目来打开本地目录。
我如何调试它??
1条答案
按热度按时间uxh89sit1#
不要将参数作为列表传递,而是尝试将它们作为字符串传递:
这应该将整个命令作为一个字符串传递给shell,shell应该正确地解释参数。