Csaba Henk
2003-May-18 13:09 UTC
[vorbis] Problems with the pyvorbis Python wrapper under Windows
Hi! The following Python code does what is excepted under Linux:>>> from ogg.vorbis import * >>> com=VorbisFile('01.ogg').comment() >>> com['title']='foo' >>> com.write_to('01.ogg')but under Windows I get the following error: Traceback (most recent call last): File "<stdin>", line 1, in ? IOError: [Errno 17] File exists (I checked the permissions of 01.ogg, 'twas writable (as it resides on a fat32 filesys...)) Is here something I should do Windows-specifically? That would be rather ugly. I don't think Python would be so ugly. I rather think it's a bug... What do you think of it? Csaba --- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'vorbis-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
Csaba Henk
2003-May-20 01:16 UTC
[vorbis] Re: Problems with the pyvorbis Python wrapper under Windows
On Mon, 19 May 2003 andrew@andrewchatham.com wrote:> Csaba, > > > I'm actually on vacation right now (and I've never used the Windows > version), but it wouldn't surprise me if I the fopen call on Windows > behaves slightly differently than on unix. The comment editing code I > mostly took from vorbiscomment program. It basically opens a new file, > writes the comments, the copies everything over from the other file. It > wouldn't surprise me if that doesn't work correctly in Windows, but I'm not > sure if there's a workaround you can do without editing the C source. I'll > look into it when I get back, though I won't really be able to test it.I think the following patch for pyvorbis should solve the problem: *<patch>******************** --- pyvorbis-1.2/src/pyvorbisinfo.c 2003-01-19 01:37:33.000000000 +0100 +++ pyvorbis-1.2-hacked/src/pyvorbisinfo.c 2003-05-20 10:13:29.000000000 +0200 @@ -1024,6 +1024,23 @@ fclose(in_file); fclose(out_file); +/* The following comment, quoted from the vorbiscomment/vcomment.c file + * of the vorbis-tools package, regards to, e.g., Windows: + * + * Some platforms fail to rename a file if the new name already exists, so + * we need to remove, then rename. How stupid. + * + * This is why the following block had to be inserted to make things work under + * Windows also. + * + * <Csaba Henk (ekho@renyi.hu)> + */ + + if (remove(filename)) { + PyErr_SetFromErrno(PyExc_IOError); + return NULL; + } + if (rename(tempfile, filename)) { PyErr_SetFromErrno(PyExc_IOError); return NULL; *</patch>********************************** <p><p>-- however, I neither can test it, as I can't compile it under Windows -- I tried to compile the py{ogg,vorbis} modules with Cygwin but it didn't succed for first and it's not as important to me as to go deep into it. Anyway, if you (anybody) will have Windows binaries for this patched pyvorbis, I'd be glad to get one. Csaba <p><p>--- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'vorbis-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.