[IPython-dev] Creation of .ipython directory
Fernando Perez
fperez.net at gmail.com
Wed Apr 1 05:37:16 EDT 2009
Hey,
sorry I never replied to this...
On Fri, Mar 20, 2009 at 9:48 PM, Brian Granger <ellisonbg.net at gmail.com> wrote:
> Hi,
>
> Previously, the only IPython command line program that used the
> .ipython directory was "ipython" itself. Now, however, other command
> line programs (ipcluster, ipcontroller, ipengine) also use the
> .ipython directory. A user just found a bug where they ran
> "ipcluster" *before* "ipython" was ever run on their system. Thus,
> "ipcluster" couldn't find the .ipython directory and an exception was
> raised.
Ugly.
> So, I have a question: where in the IPython code base is the code
> that looks to see if the .ipython directory exists and then creates it
> if not?
iplib, around line 1115:
def user_setup(self,ipythondir,rc_suffix,mode='install'):
"""Install the user configuration directory.
Can be called when running for the first time or to upgrade the user's
.ipython/ directory with the mode parameter. Valid modes are 'install'
and 'upgrade'."""
http://bazaar.launchpad.net/~ipython-dev/ipython/trunk/annotate/head%3A/IPython//iplib.py
> Should this same code be called by all IPython processes that
> might need the .ipython directory?
That seems reasonable to me, but it needs to be made more robust:
In [1]: _ip.IP.user_setup('/home/fperez/.ipython/','rc')
**********************************************************************
Welcome to IPython. I will try to create a personal configuration directory
where you can customize many aspects of IPython's functionality in:
/home/fperez/.ipython/
Initializing from configuration
/home/fperez/usr/lib/python2.5/site-packages/IPython/UserConfig
WARNING:
There was a problem with the installation:
[Errno 17] File exists: '/home/fperez/.ipython/'
Try to correct it or contact the developers if you think it's a bug.
IPython will proceed with builtin defaults.
Please press <RETURN> to start IPython.
**********************************************************************
Basically, just a matter of changing it so that it can be called
anytime and *it* checks whether that dir exists. Today, the code is
called in ipmaker:
# Create user config directory if it doesn't exist. This must be done
# *after* getting the cmd line options.
if not os.path.isdir(opts_all.ipythondir):
IP.user_setup(opts_all.ipythondir,rc_suffix,'install')
If the check was moved inside, this could safely be called at startup
by others without fear of the above error message.
Cheers,
f
More information about the IPython-dev
mailing list