[refactor] #342855: replace uses of (deprecated) mktemp
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>
Thu, 23 Jul 2009 14:51:40 +0200
changeset 2446 440cb4ea7e5c
parent 2445 6f065b366d14
child 2447 b83fcc2311af
child 2449 888d698af3f9
[refactor] #342855: replace uses of (deprecated) mktemp
common/migration.py
devtools/devctl.py
server/serverctl.py
test/unittest_cwconfig.py
web/views/__init__.py
--- a/common/migration.py	Thu Jul 23 14:45:31 2009 +0200
+++ b/common/migration.py	Thu Jul 23 14:51:40 2009 +0200
@@ -11,7 +11,7 @@
 import sys
 import os
 import logging
-from tempfile import mktemp
+import tempfile
 from os.path import exists, join, basename, splitext
 
 from logilab.common.decorators import cached
@@ -337,7 +337,7 @@
         configfile = self.config.main_config_file()
         if self._option_changes:
             read_old_config(self.config, self._option_changes, configfile)
-        newconfig = mktemp()
+        newconfig = mkstemp()
         for optdescr in self._option_changes:
             if optdescr[0] == 'added':
                 optdict = self.config.get_option_def(optdescr[1])
--- a/devtools/devctl.py	Thu Jul 23 14:45:31 2009 +0200
+++ b/devtools/devctl.py	Thu Jul 23 14:51:40 2009 +0200
@@ -254,13 +254,12 @@
         if args:
             raise BadCommandUsage('Too much arguments')
         import shutil
-        from tempfile import mktemp
+        import tempfile
         import yams
         from logilab.common.fileutils import ensure_fs_mode
         from logilab.common.shellutils import globfind, find, rm
         from cubicweb.common.i18n import extract_from_tal, execute
-        tempdir = mktemp()
-        mkdir(tempdir)
+        tempdir = tempdir.mkdtemp()
         potfiles = [join(I18NDIR, 'entities.pot')]
         print '******** extract schema messages'
         schemapot = join(tempdir, 'schema.pot')
@@ -348,14 +347,13 @@
 
 def update_cube_catalogs(cubedir):
     import shutil
-    from tempfile import mktemp
+    import tempfile
     from logilab.common.fileutils import ensure_fs_mode
     from logilab.common.shellutils import find, rm
     from cubicweb.common.i18n import extract_from_tal, execute
     toedit = []
     cube = basename(normpath(cubedir))
-    tempdir = mktemp()
-    mkdir(tempdir)
+    tempdir = tempfile.mkdtemp()
     print '*' * 72
     print 'updating %s cube...' % cube
     chdir(cubedir)
--- a/server/serverctl.py	Thu Jul 23 14:45:31 2009 +0200
+++ b/server/serverctl.py	Thu Jul 23 14:51:40 2009 +0200
@@ -649,7 +649,7 @@
         import tempfile
         srcappid = pop_arg(args, 1, msg="No source application specified !")
         destappid = pop_arg(args, msg="No destination application specified !")
-        output = tempfile.mktemp()
+        output = tempfile.mkstemp()
         if ':' in srcappid:
             host, srcappid = srcappid.split(':')
             _remote_dump(host, srcappid, output, self.config.sudo)
--- a/test/unittest_cwconfig.py	Thu Jul 23 14:45:31 2009 +0200
+++ b/test/unittest_cwconfig.py	Thu Jul 23 14:51:40 2009 +0200
@@ -8,7 +8,6 @@
 import sys
 import os
 from os.path import dirname, join, abspath
-from tempfile import mktemp
 
 from logilab.common.testlib import TestCase, unittest_main
 from logilab.common.changelog import Version
--- a/web/views/__init__.py	Thu Jul 23 14:45:31 2009 +0200
+++ b/web/views/__init__.py	Thu Jul 23 14:51:40 2009 +0200
@@ -8,7 +8,7 @@
 __docformat__ = "restructuredtext en"
 
 import os
-from tempfile import mktemp
+import tempfile
 
 from rql import nodes
 
@@ -109,7 +109,7 @@
 
     def cell_call(self, row=0, col=0):
         self.row, self.col = row, col # in case one need it
-        tmpfile = mktemp('.png')
+        tmpfile = tempfile.mkstemp('.png')
         try:
             self._generate(tmpfile)
             self.w(open(tmpfile).read())