##// END OF EJS Templates
Fix IPython.utils.warn API so messages are automatically displayed followed by a newline.
Thomas Kluyver -
Show More
@@ -137,7 +137,7 b' class HistoryAccessor(Configurable):'
137 self.hist_file = self._get_hist_file_name(profile)
137 self.hist_file = self._get_hist_file_name(profile)
138
138
139 if sqlite3 is None and self.enabled:
139 if sqlite3 is None and self.enabled:
140 warn("IPython History requires SQLite, your history will not be saved\n")
140 warn("IPython History requires SQLite, your history will not be saved")
141 self.enabled = False
141 self.enabled = False
142
142
143 if sqlite3 is not None:
143 if sqlite3 is not None:
@@ -336,7 +336,7 b' class InteractiveShell(SingletonConfigurable):'
336 'prompt_out' : 'out_template',
336 'prompt_out' : 'out_template',
337 'prompts_pad_left' : 'justify',
337 'prompts_pad_left' : 'justify',
338 }
338 }
339 warn("InteractiveShell.{name} is deprecated, use PromptManager.{newname}\n".format(
339 warn("InteractiveShell.{name} is deprecated, use PromptManager.{newname}".format(
340 name=name, newname=table[name])
340 name=name, newname=table[name])
341 )
341 )
342 # protect against weird cases where self.config may not exist:
342 # protect against weird cases where self.config may not exist:
@@ -721,7 +721,7 b' class InteractiveShell(SingletonConfigurable):'
721 return
721 return
722
722
723 warn("Attempting to work in a virtualenv. If you encounter problems, please "
723 warn("Attempting to work in a virtualenv. If you encounter problems, please "
724 "install IPython inside the virtualenv.\n")
724 "install IPython inside the virtualenv.")
725 if sys.platform == "win32":
725 if sys.platform == "win32":
726 virtual_env = os.path.join(os.environ['VIRTUAL_ENV'], 'Lib', 'site-packages')
726 virtual_env = os.path.join(os.environ['VIRTUAL_ENV'], 'Lib', 'site-packages')
727 else:
727 else:
@@ -351,7 +351,7 b' class TerminalIPythonApp(BaseIPythonApplication, InteractiveShellApp):'
351 """Replace --pylab='inline' with --pylab='auto'"""
351 """Replace --pylab='inline' with --pylab='auto'"""
352 if new == 'inline':
352 if new == 'inline':
353 warn.warn("'inline' not available as pylab backend, "
353 warn.warn("'inline' not available as pylab backend, "
354 "using 'auto' instead.\n")
354 "using 'auto' instead.")
355 self.pylab = 'auto'
355 self.pylab = 'auto'
356
356
357 def start(self):
357 def start(self):
@@ -105,7 +105,7 b' class InputHookManager(object):'
105
105
106 def __init__(self):
106 def __init__(self):
107 if ctypes is None:
107 if ctypes is None:
108 warn("IPython GUI event loop requires ctypes, %gui will not be available\n")
108 warn("IPython GUI event loop requires ctypes, %gui will not be available")
109 return
109 return
110 self.PYFUNC = ctypes.PYFUNCTYPE(ctypes.c_int)
110 self.PYFUNC = ctypes.PYFUNCTYPE(ctypes.c_int)
111 self._apps = {}
111 self._apps = {}
@@ -319,7 +319,7 b' def make_exclude():'
319 continue
319 continue
320 fullpath = pjoin(parent, exclusion)
320 fullpath = pjoin(parent, exclusion)
321 if not os.path.exists(fullpath) and not glob.glob(fullpath + '.*'):
321 if not os.path.exists(fullpath) and not glob.glob(fullpath + '.*'):
322 warn("Excluding nonexistent file: %r\n" % exclusion)
322 warn("Excluding nonexistent file: %r" % exclusion)
323
323
324 return exclusions
324 return exclusions
325
325
@@ -130,9 +130,9 b' def import_fail_info(mod_name,fns=None):'
130 """Inform load failure for a module."""
130 """Inform load failure for a module."""
131
131
132 if fns == None:
132 if fns == None:
133 warn("Loading of %s failed.\n" % (mod_name,))
133 warn("Loading of %s failed." % (mod_name,))
134 else:
134 else:
135 warn("Loading of %s from %s failed.\n" % (fns,mod_name))
135 warn("Loading of %s from %s failed." % (fns,mod_name))
136
136
137
137
138 class NotGiven: pass
138 class NotGiven: pass
@@ -42,7 +42,7 b' def warn(msg,level=2,exit_val=1):'
42
42
43 if level>0:
43 if level>0:
44 header = ['','','WARNING: ','ERROR: ','FATAL ERROR: ']
44 header = ['','','WARNING: ','ERROR: ','FATAL ERROR: ']
45 io.stderr.write('%s%s' % (header[level],msg))
45 print(header[level], msg, sep='', file=io.stderr)
46 if level == 4:
46 if level == 4:
47 print('Exiting.\n', file=io.stderr)
47 print('Exiting.\n', file=io.stderr)
48 sys.exit(exit_val)
48 sys.exit(exit_val)
General Comments 0
You need to be logged in to leave comments. Login now