Title: Temp files Post by: bvdp on May 04, 2020, 04:26:03 PM In another thread:
Quote elif gbl.playFile: import tempfile # Currently MMA requires a file name. It would be nice if it # could handle file objects... # Since otherwise we need to throw away the file handle. #(fd,outfile) = tempfile.mkstemp( prefix="MMA", suffix=".mid" ) outfile = tempfile.mktemp( prefix="MMA", suffix=".mid" ) MMA.exits.files.append(outfile) [\quote] Good idea. Any problem with prefix="MMA." ... if the first rnd character is uppercase the "MMA" part tends to get lost :) Also, it's not that MMA needs the filename (well, it is sort of), but the player probably will need one as well. Anyway, I've changed it in paths.py. I'll have a quick look for other temp files and do the same. Title: Re: Temp files Post by: sciurius on May 04, 2020, 07:19:58 PM The actual filename is not relevant, since it is explicitely passed to the MIDI player and removed afterwards. If the MIDI player can read from a pipe (timidity can) then MMA could pipe the MIDI data directly into the player without the need for a temp file.
About the MMA. prefix: I don't think it has much added value and, as a cautious programmer, I bear in mind that there may be operating systems that dislike more than one dot in a filename. Title: Re: Temp files Post by: bvdp on May 04, 2020, 09:44:10 PM Yeah, well, some players can read stdin and others can't. And then there are other OSes ... not a big deal to create a file ;)
Title: Re: Temp files Post by: bvdp on May 04, 2020, 10:01:18 PM I think we are okay with more than one '.' in a filename:
https://stackoverflow.com/questions/4642028/using-multiple-dots-in-file-names Title: Re: Temp files Post by: sciurius on May 05, 2020, 06:22:05 AM From reading the article I'd say no...
a) the poorly written filename extension checker would get confused Remove all doc and docx files: rm *.doc* -- and gone are my precious ;D MMA.doc13242.mid files. b) having MMA. prefix has no added value over whatever. It is a temp file that is going away anyway. Personally I don't care. |