I'm using Python 2.6.2 as packaged with Fedora 12. I'm trying to use
subprocess.Popen() to call /usr/bin/pactl, a simple PulseAudio command
parser.

I'm having a hard time, because it only works part of the time. If pactl
gets a blank or invalid command, it says "No valid command specified.", and
this is what prints to stderr most of the time. I can get the result of
"pactl list", but anything else I try returns "No valid command specified."
So, pactl is getting called, but my args are disappearing somewhere. But not
every time...

Below is a test case that demonstrates this. Tests 1 & 2 concatenate the
command and the argument, Tests 3 & 4 mimic the python docs and use the form
Popen(["mycmd", "myarg"], ...), which never seems to work.

import subprocess

list = 'list'
list_sinks = 'list-sinks'

print("### TEST 1")
a = subprocess.Popen('pactl ' + list, shell=True, stdout=subprocess.PIPE)
res = a.communicate()
print(repr(res[0]))

print("### TEST 2")
a = subprocess.Popen('pactl ' + list_sinks, shell=True,
stdout=subprocess.PIPE)
res = a.communicate()
print(repr(res[0]))

print("### TEST 3")
a = subprocess.Popen(['pactl', list], shell=True, stdout=subprocess.PIPE)
res = a.communicate()
print(repr(res[0]))

print("### TEST 4")
a = subprocess.Popen(['pactl', list_sinks], shell=True,
stdout=subprocess.PIPE)
res = a.communicate()
print(repr(res[0]))
### TEST 1
(success... snip)
### TEST 2
No valid command specified.
''
### TEST 3
No valid command specified.
''
### TEST 4
No valid command specified.
''

Does anyone have any idea what I'm doing wrong?
Thanks,
John
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to