From fcb8d0f1abd0a490abf1a7135f1d05593d9d542b Mon Sep 17 00:00:00 2001 From: David Cantrell Date: Sat, 4 Oct 2008 20:29:59 -1000 Subject: [PATCH] Open the file descriptor returned from mkstemp(). We get a file descriptor as returned by os.open() when calling tempfile.mkstemp(), so we need to pass that value to os.fdopen() before we can write text to it (easily, anyway). --- src/pylorax/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pylorax/__init__.py b/src/pylorax/__init__.py index 4c98c3b4..a32ef3c3 100644 --- a/src/pylorax/__init__.py +++ b/src/pylorax/__init__.py @@ -113,7 +113,8 @@ def writeYumConf(cachedir=None, repo=None, extrarepos=[], mirrorlist=[]): return None tmpdir = tempfile.gettempdir() - (f, yumconf) = tempfile.mkstemp(prefix='yum.conf', dir=tmpdir) + (fd, yumconf) = tempfile.mkstemp(prefix='yum.conf', dir=tmpdir) + f = os.fdopen(fd, 'w') f.write("[main]\n") f.write("cachedir=%s\n" % (cachedir,)) @@ -146,6 +147,7 @@ def writeYumConf(cachedir=None, repo=None, extrarepos=[], mirrorlist=[]): n += 1 f.close() + fd.close() return yumconf def getBuildArch(yumconf=None):