tempfile.mkstemp problem?

marco marco at reimeika.ca
Thu Jul 29 07:47:41 CEST 2004

The last one! For real!

marco <marco at reimeika.ca> writes:

> I first create the dir as follows:
> work_dir = opts.get('-w', img_dir)
> work_dir = os.path.abspath(work_dir)
> if not os.path.isdir(work_dir):
>     if not quiet: print 'Creating ' + work_dir
>     try:
>         os.makedirs(work_dir)
>     except:
>         print 'Could not create the work directory ' + \
>               work_dir
>         raise SystemExit
> This works fine. To make sure, I even added a check right
> before making the tempfile:
> print os.path.isdir('/tmp/991319584/metd/')
> mpegv = tempfile.mkstemp('.mpv', '', work_dir)[1]
> The "os.path.isdir" says "True". Here's the kicker:
> after the tempfile.mkstemp error, the "metd" directory
> disappears! It's deleted!

If I create the "metd" dir by hand before calling the plugin
from the GUI everything works! This is really puzzling:

If the "metd" doesn't exist the Python script _appears_
to create it, but somehow tempfile.mkstemp can't put the
tempfile inside. If, on the other hand, I create that
directory beforehand there's no problem. What's
going on? Is 


lying to me when it says "True"? Is the "metd" actually
there but in some weird state which messes up tempfile.mkstemp?

I guess I could try making the temp dir from within
the plugin instead (and then calling the script afterwards).
This is all very strange, though...

Anyway, sorry again for all the posts, it's really late! :/


marco at reimeika.ca
Gunnm: Broken Angel                      http://amv.reimeika.ca
http://reimeika.ca/                      http://photo.reimeika.ca

More information about the Python-list mailing list