easy problems, hard to fix?
Duncan Booth
duncan at NOSPAMrcp.co.uk
Fri May 9 05:22:20 EDT 2003
bunger00 at grm.hia.no (Bunger) wrote in
news:2ba63562.0305090057.2e009bce at posting.google.com:
> I'm wondering what is wrong with this code. I use this program in
> windows. I suspect that I don't have sys from "import sys" on my
> computer. Is this the problem? and how can I fix it? This program is
> transelated from linux. Please help me.
>
>
> this is the error messeges I get:
<snip>
> execPip.wait()
> AttributeError: 'tuple' object has no attribute 'wait'
The error message says that execPip is a tuple.
<snip>
> def encode(file, store=OUTDIR):
> execStr = "%s -i %s -o %s" % (ENCPATH, os.path.basename(file),
> os.path.join(store, os.path.basename(file)[:-4] + ".3gp"))
> execPip = popen2.popen3(execStr)
> execPip.wait()
> os.rename(file, os.path.join(FINDIR, os.path.basename(file)))
Read the documentation for the popen2.popen3 function. It returns a tuple
(which is what the error message was telling you). While you are at it,
read the paragraph just above the documentation for the popen3 function:
"The only way to retrieve the return codes for the child processes is by
using the poll() or wait() methods on the Popen3 and Popen4 classes; these
are only available on Unix. This information is not available when using
the popen2(), popen3(), and popen4() functions, or the equivalent functions
in the os module."
If you don't want the output from the command, you might be better using
os.system or os.spawnl here. If you do want the output, then read from the
file handles and the program will have completed when the read completes.
--
Duncan Booth duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
More information about the Python-list
mailing list