#15972: IPython ProfileDirError if IPython was never run
------------------------------+------------------------
       Reporter:  jdemeyer    |        Owner:
           Type:  defect      |       Status:  new
       Priority:  blocker     |    Milestone:  sage-6.2
      Component:  interfaces  |   Resolution:
       Keywords:              |    Merged in:
        Authors:              |    Reviewers:
Report Upstream:  N/A         |  Work issues:
         Branch:              |       Commit:
   Dependencies:              |     Stopgaps:
------------------------------+------------------------

Comment (by jhpalmieri):

 This seems to fix it. Is the right approach?
 {{{
 #!diff
 diff --git a/src/sage/misc/interpreter.py b/src/sage/misc/interpreter.py
 index aff78f7..349e9dc 100644
 --- a/src/sage/misc/interpreter.py
 +++ b/src/sage/misc/interpreter.py
 @@ -614,7 +614,7 @@ class SageTerminalApp(TerminalIPythonApp):

      def load_config_file(self, *args, **kwds):
          from IPython.config.loader import PyFileConfigLoader,
 ConfigFileNotFound
 -        from IPython.core.profiledir import ProfileDir
 +        from IPython.core.profiledir import ProfileDir, ProfileDirError
          from IPython.utils.path import get_ipython_dir

          conf = Config()
 @@ -622,8 +622,13 @@ class SageTerminalApp(TerminalIPythonApp):
          conf._merge(self.command_line_config)

          # Get user config.
 -        sage_profile_dir = ProfileDir.find_profile_dir_by_name(
 -            get_ipython_dir(), 'sage').location
 +        try:
 +            sage_profile_dir = ProfileDir.find_profile_dir_by_name(
 +                get_ipython_dir(), 'sage').location
 +        except ProfileDirError:
 +            d = ProfileDir.create_profile_dir_by_name(
 +                get_ipython_dir(), 'sage')
 +            sage_profile_dir = d.location
          try:
              cl = PyFileConfigLoader('ipython_config.py',
 sage_profile_dir)
              conf._merge(cl.load_config())
 }}}

--
Ticket URL: <http://trac.sagemath.org/ticket/15972#comment:1>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to