I actually tried subprocess.check_output before resorting to executeCommandLine. For me, subprocess.check_output didn’t work. It caused a python error about popen argument being wrong or missing argument.
executeCommandLine is not bad if you break it down. Basically it wants the “arguments” (not space - the document is unclear and misleading) separated by @@. I should probably create a PR to edit the doc
Here’s an excerpt:
def get_command(self, url, params):
command = ["/usr/bin/curl", "-s", "-H", self.header, self.get_url(path, params)]
return "@@".join(command)
...
def something(self, blahblah)
output = Exec.executeCommandLine(self.get_command(path, params), 10000)
Note that there can be spaces in self.header, path / params etc. Once you’ve figured this out, executeCommandLine isn’t so bad.
See, in the unix shell, you would call curl like this:
curl -s -H 'Header: blah blah' 'https://xxx.yy.zz/path?blahblah'
You would enclose the argument containing spaces with single or double quotes to tell the shell that it’s a part of a single argument. The shell will strip them off before passing them to the program (curl). With executeCommandLine, such syntax is not needed because it uses @@
as an argument separator, so spaces do not cause ambiguity as to whether it’s a part of the argument or an argument separator.
Sure, subprocess is a lot more versatile with input/output. I just wish I could make it work, and I didn’t spend too much time bothering with it. Maybe I will… and I’ll ping @rlkoshak
Hmmmm… I never got that far with subprocess. Did it fail because of the lack of timeout?
That would probably be the ideal. Anyone working on it?