下面的Python脚本中需要更改哪些特定语法才能将个人访问令牌成功读取到az devops login
命令中而不会引发错误?
当前错误:
当前抛出的错误为:
'actual-personal-access-token-goes-here' is not recognized as an internal or external command, operable program or batch file.
呼叫程序:
抛出错误时从windows CMD调用的Python程序称为myScript.py
,包括:
import subprocess
import re
ansi_escape = re.compile(r'x1B[[0-?]*[ -/]*[@-~]')
azPat = 'actual-personal-access-token-goes-here'
orgServiceURL = 'actual-org-service-url-goes-here'
azdoLoginCmd='az devops login --organization '+orgServiceURL
dblCmd = azPat + " | " + azdoLoginCmd
proc = subprocess.Popen( dblCmd,cwd=None, stdout=subprocess.PIPE, shell=True)
while True:
line = proc.stdout.readline()
if line:
thetext=line.decode('utf-8').rstrip('r|n')
decodedline=ansi_escape.sub('', thetext)
print(decodedline)
else:
break
调用发票程序:
在windows CMD中键入的调用上述程序并抛出上述错误的命令是:
python3 myScript.py
官方文档:
Microsoft官方文档位于此链接中。
以下是解决OP中错误的方法:
azdoLoginCmd= "ECHO " + azPat + " | " + "az devops login --organization "+organization
我们对此进行了测试以验证它