I know I’m doing something wrong.
In the shell i would type:
cuebreakpoints cuefile.cue | shnsplit -o flac flacfile.flac
This would then split the flac file according to the cuefile. Since I’m in the process of writing a small help tool (in Python) to convert flac files I obviously wanted to incorporate this bit in my code.
So in a pythonic way I wrote:
for root, dirs, files in os.walk(args):
...
cmd = ('cuebreakpoints', cue, '|', 'shnsplit', '-o', 'flac', flacs[0])
subprocess.check_call(cmd, cwd=None)
....
‘cue’ being the cuefile and ‘flacs[0]’ being the flac file. However I get a:
subprocess.CalledProcessError: Command ‘(‘cuebreakpoints’, ’41_30sec.cue’, ‘|’, ‘shnsplit’, ‘-o’, ‘flac’, ’41_30sec.flac’)’ returned non-zero exit status 1
Is there a problem because of the PIPE ?
As an alternative to passing the command string to a shell (and skip the security problems pointed out by larsmans), you can create two
subprocess.Popenobjects and connect the output of the first one to the input of the second one (that’s basically what the shell will do for you):For an example about how to do that, please have a look at the replacing shell pipeline section in the documentation.