2

I am trying to execute the RaptorXML+XBRL command through subprocess.call() from a python script. The syntax is:

result = call(["/opt/Altova/RaptorXMLXBRLServer2015/bin/raptorxmlxbrl xbrl","--listfile", joblist],shell=True )

Where joblist = "valSECfilings.jobs". But when I execute this python script I get this error:

Error: No value for mandatory argument 'FILE' specified.
Usage:
   raptorxmlxbrl valxbrl [options] FILE...

   valxbrl can be abbreviated with: xbrl

When I execute this command directly on the terminal I do not get any error:

/opt/Altova/RaptorXMLXBRLServer2015/bin/raptorxmlxbrl xbrl --listfile "valSECfilings.jobs"

Can anyone help me pointing what might be wrong here and how to resolve it?

user2966197
  • 2,793
  • 10
  • 45
  • 77

1 Answers1

0

The Python documentation is unfortunately somewhat unclear on this point, but when you pass shell=True to subprocess.call, the args parameter is supposed to be a single string instead of a list. It should be a list of the command and individual argments if shell=False (the default).

So both of these are correct:

result = call(["/opt/Altova/RaptorXMLXBRLServer2015/bin/raptorxmlxbrl", "xbrl", "--listfile", joblist])

or

result = call("/opt/Altova/RaptorXMLXBRLServer2015/bin/raptorxmlxbrl xbrl --listfile " + joblist, shell=True)

I'd prefer the first (non-shell) version because the second one means you have to make sure the joblist string doesn't contain spaces or improper quote characters.

matts
  • 6,738
  • 1
  • 33
  • 50
  • True, the space is the problem. When you call "/opt/Altova/RaptorXMLXBRLServer2015/bin/raptorxmlxbrl_SPACE_xbrl" is not interpreted as "raptorxmlxbrl" and the argument "xbrl" but as a command "raptorxmlxbrl xbrl", which obviously does not exists as an executable. Frankly the documentation is pretty clear about that and it also has a very easy to analyze example: subprocess.call(["ls", "-l"]) – rbaleksandar Jul 30 '15 at 16:15
  • Examples do not suffice as proper documentation, IMO. However, upon re-reading the documentation I'll note that there is a comprehensive explanation of how `args` is interpreted, but it's under the `subprocess.Popen` section, and you have to read 6 paragraphs before you get to the part that explains exactly how a sequence is interpreted on Unix. – matts Jul 30 '15 at 16:25
  • Of course example != documentation. I just mentioned that it is a nice way to illustrate what is already explained there. But I guess it is confusing to have to look at Popen when you just want to use call(). This should be changed by at least adding a link in the call() section to the place where args is explained in a greater detail. – rbaleksandar Jul 30 '15 at 17:28