Reputation: 723
I am running into following error ,line 158 where the error is pointing is shown below.can anyone help what is the issue and how to over come it?
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
Error:-
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
Upvotes: 1
Views: 4145
Reputation: 28390
Try:
xargs = ['change:%s' % str(num)]
This will ensure that all the parts are strings.
Personally in your error handler I would also set d = {}
rather than return {}
to make sure that you only have one return
.
Upvotes: 3