Re: Creating a temporary file in Python
- From: "Diez B. Roggisch" <deets@xxxxxxxxxxxxx>
- Date: Wed, 31 Oct 2007 13:16:10 +0100
looping wrote:
Hi,
I want to create a temporary file, read it in an external command and
finally delete it (in Windows XP).
I try to use tempfile module but it doesn't work, the file couldn't be
open by my other process (error like: SP2-0310: unable to open file "c:
\docume~1\looping\locals~1\temp\tmpau81-s.sql")
Is there a way to make it work or I have to manually manage
everything ?
My non working code:
f = tempfile.NamedTemporaryFile(suffix='.sql')
f.write(txt)
f.flush()
p = subprocess.Popen([SQL_PLUS, '-s', dsn, '@', SQL_PLUS_SCRIPT,
f.name],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
p.wait()
f.close()
I'm not an expert, but I think you need to close the file first - you under
windows here, which can be picky about such stuff AFAIK. Or maybe there is
some other mode-specifier.
Diez
.
- Follow-Ups:
- Re: Creating a temporary file in Python
- From: looping
- Re: Creating a temporary file in Python
- References:
- Creating a temporary file in Python
- From: looping
- Creating a temporary file in Python
- Prev by Date: Re: setting variables in outer functions
- Next by Date: Re: A Python 3000 Question
- Previous by thread: Creating a temporary file in Python
- Next by thread: Re: Creating a temporary file in Python
- Index(es):
Relevant Pages
|