##// END OF EJS Templates
remove mktemp usage...
Julian Taylor -
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:
@@ -95,7 +95,8 b' def write_connection_file(fname=None, shell_port=0, iopub_port=0, stdin_port=0, '
95 ip = localhost()
95 ip = localhost()
96 # default to temporary connector file
96 # default to temporary connector file
97 if not fname:
97 if not fname:
98 fname = tempfile.mktemp('.json')
98 fd, fname = tempfile.mkstemp('.json')
99 os.close(fd)
99
100
100 # Find open ports as necessary.
101 # Find open ports as necessary.
101
102
@@ -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
@@ -21,7 +21,7 b' import sys'
21 import platform
21 import platform
22 import time
22 import time
23 from collections import namedtuple
23 from collections import namedtuple
24 from tempfile import mktemp
24 from tempfile import NamedTemporaryFile
25
25
26 import zmq
26 import zmq
27 from nose.plugins.attrib import attr
27 from nose.plugins.attrib import attr
@@ -164,13 +164,12 b' class TestView(ClusterTestCase):'
164
164
165 def test_run_newline(self):
165 def test_run_newline(self):
166 """test that run appends newline to files"""
166 """test that run appends newline to files"""
167 tmpfile = mktemp()
167 with NamedTemporaryFile('w', delete=False) as f:
168 with open(tmpfile, 'w') as f:
169 f.write("""def g():
168 f.write("""def g():
170 return 5
169 return 5
171 """)
170 """)
172 v = self.client[-1]
171 v = self.client[-1]
173 v.run(tmpfile, block=True)
172 v.run(f.name, block=True)
174 self.assertEqual(v.apply_sync(lambda f: f(), pmod.Reference('g')), 5)
173 self.assertEqual(v.apply_sync(lambda f: f(), pmod.Reference('g')), 5)
175
174
176 def test_apply_tracked(self):
175 def test_apply_tracked(self):
@@ -152,7 +152,9 b' def default_config():'
152 config.TerminalInteractiveShell.colors = 'NoColor'
152 config.TerminalInteractiveShell.colors = 'NoColor'
153 config.TerminalTerminalInteractiveShell.term_title = False,
153 config.TerminalTerminalInteractiveShell.term_title = False,
154 config.TerminalInteractiveShell.autocall = 0
154 config.TerminalInteractiveShell.autocall = 0
155 config.HistoryManager.hist_file = tempfile.mktemp(u'test_hist.sqlite')
155 f = tempfile.NamedTemporaryFile(suffix=u'test_hist.sqlite', delete=False)
156 config.HistoryManager.hist_file = f.name
157 f.close()
156 config.HistoryManager.db_cache_size = 10000
158 config.HistoryManager.db_cache_size = 10000
157 return config
159 return config
158
160
General Comments 0
You need to be logged in to leave comments. Login now