Using Subprocess Module With Curl Command
I'm getting the error: function' object is unsubscriptable when using the subprocess module with curl command. cmd (subprocess.check_call ['curl -X POST -u 'opt:gggguywqydfydwfh' '
Solution 1:
You forgot the parens with check_call
:
subprocess.check_call(["curl", "-X", "POST", "-u", "opt:gggguywqydfydwfh",Url + 'job/%s/%s/promotion/' % (job, Num)])
You are trying to subprocess.check_call[...
You are also passing it to your function, check_call
returns the exit code so you are trying to pass 0
to your Popen call as sh
which is going to fail.
If you actually want the output, forget the function and use check_output
, you also need to pass a list of args:
out = subprocess.check_output(["curl", "-X", "POST", "-u", "opt:gggguywqydfydwfh", Url + 'job/%s/%s/promotion/' % (job, Num)])
Either way passing check_call to Popen is not the way to go
Post a Comment for "Using Subprocess Module With Curl Command"