##// END OF EJS Templates
BF(BK): cleanup tempdir in EmbeddedSphinxShell atexit
Yaroslav Halchenko -
Show More
@@ -126,12 +126,14 b' from __future__ import print_function'
126 #-----------------------------------------------------------------------------
126 #-----------------------------------------------------------------------------
127
127
128 # Stdlib
128 # Stdlib
129 import atexit
129 import os
130 import os
130 import re
131 import re
131 import sys
132 import sys
132 import tempfile
133 import tempfile
133 import ast
134 import ast
134 import warnings
135 import warnings
136 import shutil
135
137
136 # To keep compatibility with various python versions
138 # To keep compatibility with various python versions
137 try:
139 try:
@@ -295,6 +297,7 b' class EmbeddedSphinxShell(object):'
295 # Create and initialize global ipython, but don't start its mainloop.
297 # Create and initialize global ipython, but don't start its mainloop.
296 # This will persist across different EmbededSphinxShell instances.
298 # This will persist across different EmbededSphinxShell instances.
297 IP = InteractiveShell.instance(config=config, profile_dir=profile)
299 IP = InteractiveShell.instance(config=config, profile_dir=profile)
300 atexit.register(self.cleanup)
298
301
299 # io.stdout redirect must be done after instantiating InteractiveShell
302 # io.stdout redirect must be done after instantiating InteractiveShell
300 io.stdout = self.cout
303 io.stdout = self.cout
@@ -312,6 +315,7 b' class EmbeddedSphinxShell(object):'
312
315
313 self.input = ''
316 self.input = ''
314 self.output = ''
317 self.output = ''
318 self.tmp_profile_dir = tmp_profile_dir
315
319
316 self.is_verbatim = False
320 self.is_verbatim = False
317 self.is_doctest = False
321 self.is_doctest = False
@@ -332,6 +336,9 b' class EmbeddedSphinxShell(object):'
332 for line in exec_lines:
336 for line in exec_lines:
333 self.process_input_line(line, store_history=False)
337 self.process_input_line(line, store_history=False)
334
338
339 def cleanup(self):
340 shutil.rmtree(self.tmp_profile_dir, ignore_errors=True)
341
335 def clear_cout(self):
342 def clear_cout(self):
336 self.cout.seek(0)
343 self.cout.seek(0)
337 self.cout.truncate(0)
344 self.cout.truncate(0)
General Comments 0
You need to be logged in to leave comments. Login now