On Saturday, 4 March 2017 11:29:19 GMT Ralph Corderoy wrote:
> > I then use a bit of string concatenation in a loop to create a string
> > called mp3_files.
> 
> But you don't want a string, you want a list, as we both agree.  And
> you've got one.  :-)

Actually, I've never agreed to anything in that respect :-)  However, I did 
start off trying to pass the list to the mpg321 command, using a number of 
different methods to 'join' it, with no success.

Since then, I've been trying to replicate what happens in the shell and if I 
paste a single string containing space-separated filenames after the mpg321, it 
works.

Clearly, the subprocess.Popen doesn't work like that, as I'm beginning to 
dimly accept.

> > If I put it into my subrocess call as:
> >     mp3_player = subprocess.Popen(['mpg321', mp3_files])
> > 
> > it raises no complaint, but nothing plays.
> 
> I would expect mpg321 to complain on stderr that file `./foo ./bar
> ./xyzzy' can't be found, i.e. there's no directory called `foo .'.  But
> you're probably discarding stderr in your tests.  (Can't you leave
> stdout and stderr be their default None so mpg321's output goes to the
> same place as your scripts?  You're using its -q option to quieten it.)

I'm not.  I am only passing the basic mpg321 command to the 
subprocess.Popen(), so where should I look for stderr?  It's not in the same 
directory as my scripts.  I thought that by default it went to the console 
where the command was issued, which clearly doesn't apply here.

> You need to join your mp3_files list onto the end of your
> fixed-arguments list so Popen() gets the one long list of
> already-separated it needs.

This is the rub.  I've tried replicating the working code from the Change 
Rings function by saying:

        mp3_player = subprocess.Popen(['mpg321', mp3_list])

and I get the error:

        TypeError: execv() arg 2 must contain only strings

So what kind of join did you have in mind?

-- 



                Terry Coles

-- 
Next meeting:  Bournemouth, Tuesday, 2017-03-07 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
New thread:  mailto:[email protected] / CHECK IF YOU'RE REPLYING
Reporting bugs well:  http://goo.gl/4Xue     / TO THE LIST OR THE AUTHOR

Reply via email to