python: How does subprocess.check_output create it's calls? -
i'm trying read duration of video files using mediainfo. shell command works
mediainfo --inform="video;%duration/string3%" file and produces output like
00:00:33.600 but when try run in python line
subprocess.check_output(['mediainfo', '--inform="video;%duration/string3%"', file]) the whole --inform thing ignored , full mediainfo output instead.
is there way see command constructed subprocess see what's wrong?
or can tell what's wrong?
try:
subprocess.check_output(['mediainfo', '--inform=video;%duration/string3%', file]) the " in python string passed on mediainfo, can't parse them , ignore option.
these kind of problems caused shell commands requiring/swallowing various special characters. quotes such " removed bash due shell magic. in contrast, python not require them magic, , replicate them way used them. why use them if wouldn't need them? (well, d'uh, because bash makes believe need them).
for example, in bash can do
$ dd of="foobar" and write file named foobar, swallowing quotes.
in python, if do
subprocess.check_output(["dd", 'of="barfoo"', 'if=foobar']) it write file named "barfoo", keeping quotes.
Comments
Post a Comment