[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[minion-cvs] Use tempfile.mkdtemp where available
Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.seul.org:/tmp/cvs-serv1372/lib/mixminion
Modified Files:
testSupport.py
Log Message:
Use tempfile.mkdtemp where available
Index: testSupport.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/testSupport.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- testSupport.py 21 Oct 2002 02:32:49 -0000 1.5
+++ testSupport.py 21 Nov 2002 19:43:29 -0000 1.6
@@ -112,16 +112,24 @@
global _MM_TESTING_TEMPDIR_COUNTER
if _MM_TESTING_TEMPDIR is None:
import tempfile
- temp = tempfile.mktemp()
- paranoia = _MM_TESTING_TEMPDIR_PARANOIA
- if paranoia and os.path.exists(temp):
- print "I think somebody's trying to exploit mktemp."
- sys.exit(1)
- try:
- os.mkdir(temp, 0700)
- except OSError, e:
- print "Something's up with mktemp: %s" % e
- sys.exit(1)
+ paranoia = _MM_TESTING_TEMPDIR_PARANOIA
+ if hasattr(tempfile, 'mkdtemp'):
+ try:
+ temp = tempfile.mkdtemp()
+ except OSError, e:
+ print "mkdtemp failure: %s" % e
+ sys.exit(1)
+ else:
+ temp = tempfile.mktemp()
+ if paranoia and os.path.exists(temp):
+ print "I think somebody's trying to exploit mktemp."
+ sys.exit(1)
+ try:
+ os.mkdir(temp, 0700)
+ except OSError, e:
+ print "Something's up with mktemp: %s" % e
+ sys.exit(1)
+
if not os.path.exists(temp):
print "Couldn't create temp dir %r" %temp
sys.exit(1)