如何从Python可靠地确定/usr/bin/vlc的版本?

如何从Python可靠地确定/usr/bin/vlc的版本?,python,version,subprocess,vlc,Python,Version,Subprocess,Vlc,比如说, subprocess.Popen(["/usr/bin/vlc", "--version"], stderr=subprocess.PIPE, stdout=subprocess.PIPE).communicate() 在我的电脑上导致 ('VLC version 2.0.2 Twoflower (.....see the AUTHORS file.\n', '') # longish text in stdout with versions, including GCC versi

比如说,

subprocess.Popen(["/usr/bin/vlc", "--version"], stderr=subprocess.PIPE, stdout=subprocess.PIPE).communicate()
在我的电脑上导致

('VLC version 2.0.2 Twoflower (.....see the AUTHORS file.\n', '')
# longish text in stdout with versions, including GCC version, date
# nothing on stderr
在另一台计算机上,它会导致

('', 'VLC media player 1.1.3 The Luggage (revision exported)\n')
# on stderr
还有(奇怪的):


怎么了?我应该依靠什么?

看起来他们把
--version
的输出从stderr切换到了stdout。您必须同时检查两者。

似乎VLC 2以与VLC 1至标准兼容的格式输出了可解析的版本。。。但只有当stderr在tty上时。。。
mycomp> /usr/bin/vlc --version 2>&1 > /dev/null
VLC media player 2.0.2 Twoflower (revision 2.0.1-453-g40d9fef)
mycomp> perl -e 'print `/usr/bin/vlc --version 2>&1 > /dev/null`'
(no output at all)
mycomp> /usr/bin/vlc --version 2>&1 > /dev/null | cat
(no output at all)
mycomp> socat system:'/usr/bin/vlc --version > /dev/null',stderr -
(no output at all)
mycomp> socat system:'/usr/bin/vlc --version > /dev/null',pty,stderr -
VLC media player 2.0.2 Twoflower (revision 2.0.1-453-g40d9fef)
mycomp> strace -o /tmp/2 -e write  /usr/bin/vlc --version 2>&1 > /dev/null | cat
(no output at all)
mycomp> cat /tmp/2
write(1, "VLC version 2.0.2 Twoflower (2.0"..., 401) = 401
mycomp> strace -f -o `tty` -e write  /usr/bin/vlc  --version > /dev/null 2> /dev/tty2
3628  write(2, "VLC media player 2.0.2 Twoflower"..., 63) = 63
3628  write(1, "VLC version 2.0.2 Twoflower (2.0"..., 401) = 401
strace -f -o `tty` -e write  /usr/bin/vlc  --version > /dev/null 2> /dev/null
3587  write(1, "VLC version 2.0.2 Twoflower (2.0"..., 401) = 401
# sad, seems to be "too clevel"-type of bug.


othercomp> perl -e 'print `/usr/bin/vlc --version 2>&1 > /dev/null`'
VLC media player 1.1.3 The Luggage (revision exported)
othercomp> /usr/bin/vlc --version 2>&1 > /dev/null
VLC media player 1.1.3 The Luggage (revision exported)