TypeError: execv() arg 2 must contain only strings

前端 未结 2 1706
故里飘歌
故里飘歌 2021-01-04 00:23

I am getting the following error when running the script below,can anyhelp to identify what the problem is and how to overcome it

import subprocess
import sy         


        
相关标签:
2条回答
  • 2021-01-04 00:38

    First you need to add the quotes around 29418 as mgilson mentioned. Second let's break down what you're trying to run:

    ssh_command = ["ssh", "-p", 29418, "review-android.company.com", "gerrit",
                   "query", "--format", "JSON", "--current-patch-set",
                   "--commit-message", "--files", ]
    

    That equals

    ssh -p 29418 review-android.company.com gerrit query --format JSON --current-patch-set --commit-message --files
    (then I'm assuming you have filenames in your caf_gerrits.txt file which get appended at the end)
    

    One thing that pops out at me is that you may want to say --format=JSON in which case your elements in the ssh_command array should be combined as [..., "--format=JSON", ...]. The other thing you may want to do is print result after your result= line to help with the debugging.

    0 讨论(0)
  • 2021-01-04 00:48

    The third element in ssh_command is an integer. It needs to be a string.

    e.g:

    ssh_command = ["ssh", "-p", 29418, ...
    #                            ^ problem
    

    And the solution is simple, just add some quotes:

    ssh_command = ["ssh", "-p", "29418", ...
    #                           ^Now it's a string.
    
    0 讨论(0)
提交回复
热议问题