##// END OF EJS Templates
Backport PR #5166: remove mktemp usage...
MinRK -
Show More
@@ -208,15 +208,18 b' def page(strng, start=0, screen_lines=0, pager_cmd=None):'
208 # The default WinXP 'type' command is failing on complex strings.
208 # The default WinXP 'type' command is failing on complex strings.
209 retval = 1
209 retval = 1
210 else:
210 else:
211 tmpname = tempfile.mktemp('.txt')
211 fd, tmpname = tempfile.mkstemp('.txt')
212 tmpfile = open(tmpname,'wt')
212 try:
213 os.close(fd)
214 with open(tmpname, 'wt') as tmpfile:
213 tmpfile.write(strng)
215 tmpfile.write(strng)
214 tmpfile.close()
215 cmd = "%s < %s" % (pager_cmd,tmpname)
216 cmd = "%s < %s" % (pager_cmd, tmpname)
217 # tmpfile needs to be closed for windows
216 if os.system(cmd):
218 if os.system(cmd):
217 retval = 1
219 retval = 1
218 else:
220 else:
219 retval = None
221 retval = None
222 finally:
220 os.remove(tmpname)
223 os.remove(tmpname)
221 else:
224 else:
222 try:
225 try:
@@ -92,7 +92,8 b' def write_connection_file(fname=None, shell_port=0, iopub_port=0, stdin_port=0, '
92 """
92 """
93 # default to temporary connector file
93 # default to temporary connector file
94 if not fname:
94 if not fname:
95 fname = tempfile.mktemp('.json')
95 fd, fname = tempfile.mkstemp('.json')
96 os.close(fd)
96
97
97 # Find open ports as necessary.
98 # Find open ports as necessary.
98
99
@@ -20,7 +20,6 b' from __future__ import division'
20
20
21 import time
21 import time
22 from datetime import datetime
22 from datetime import datetime
23 from tempfile import mktemp
24
23
25 import zmq
24 import zmq
26
25
@@ -20,7 +20,7 b' import sys'
20 import platform
20 import platform
21 import time
21 import time
22 from collections import namedtuple
22 from collections import namedtuple
23 from tempfile import mktemp
23 from tempfile import NamedTemporaryFile
24 from StringIO import StringIO
24 from StringIO import StringIO
25
25
26 import zmq
26 import zmq
@@ -166,13 +166,12 b' class TestView(ClusterTestCase, ParametricTestCase):'
166
166
167 def test_run_newline(self):
167 def test_run_newline(self):
168 """test that run appends newline to files"""
168 """test that run appends newline to files"""
169 tmpfile = mktemp()
169 with NamedTemporaryFile('w', delete=False) as f:
170 with open(tmpfile, 'w') as f:
171 f.write("""def g():
170 f.write("""def g():
172 return 5
171 return 5
173 """)
172 """)
174 v = self.client[-1]
173 v = self.client[-1]
175 v.run(tmpfile, block=True)
174 v.run(f.name, block=True)
176 self.assertEqual(v.apply_sync(lambda f: f(), pmod.Reference('g')), 5)
175 self.assertEqual(v.apply_sync(lambda f: f(), pmod.Reference('g')), 5)
177
176
178 def test_apply_tracked(self):
177 def test_apply_tracked(self):
@@ -150,7 +150,9 b' def default_config():'
150 config.TerminalInteractiveShell.colors = 'NoColor'
150 config.TerminalInteractiveShell.colors = 'NoColor'
151 config.TerminalTerminalInteractiveShell.term_title = False,
151 config.TerminalTerminalInteractiveShell.term_title = False,
152 config.TerminalInteractiveShell.autocall = 0
152 config.TerminalInteractiveShell.autocall = 0
153 config.HistoryManager.hist_file = tempfile.mktemp(u'test_hist.sqlite')
153 f = tempfile.NamedTemporaryFile(suffix=u'test_hist.sqlite', delete=False)
154 config.HistoryManager.hist_file = f.name
155 f.close()
154 config.HistoryManager.db_cache_size = 10000
156 config.HistoryManager.db_cache_size = 10000
155 return config
157 return config
156
158
General Comments 0
You need to be logged in to leave comments. Login now