我遇到了以下错误,错误指向的第158行如下所示。任何人都可以帮助解决问题以及如何解决问题?
def getGerritInfo(num):
user = pwd.getpwuid(os.getuid())[0]
gerritCmd = ("ssh -p 29418 review-android.quicinc.com gerrit query --format=JSON --dependencies ").split(' ')
xargs = ['change:'+num]
gerritPipe = Popen(gerritCmd+xargs, stdout=PIPE, stderr=PIPE) --> line 158
(output, error) = gerritPipe.communicate()
if error != "":
print error
raise IOError, "gerrit command %s failed" % (gerritCmd)
d = json.loads(output.split('\n')[0])
if len(d) == 3:
return {}
return d
错误: -
File "find_dependencies.py", line 437, in <module>
main()
File "find_dependencies.py", line 211, in main
(dep_gerrit,depgerrit_status,depgerrit_error)=findinternaldep(internal_dep,num)
File "find_dependencies.py", line 100, in findinternaldep
gerrit = getGerritInfo(change)
File "find_dependencies.py", line 158, in getGerritInfo
gerritPipe = Popen(gerritCmd+xargs, stdout=PIPE, stderr=PIPE)
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
TypeError: execv() arg 2 must contain only strings
答案 0 :(得分:3)
尝试:
xargs = ['change:%s' % str(num)]
这将确保所有部分都是字符串。
在您的错误处理程序中,我个人也会设置d = {}
而不是return {}
,以确保您只有一个return
。