Show More
@@ -3,7 +3,7 b'' | |||||
3 | An application for IPython. |
|
3 | An application for IPython. | |
4 |
|
4 | |||
5 | All top-level applications should use the classes in this module for |
|
5 | All top-level applications should use the classes in this module for | |
6 |
handling configuration and creating co |
|
6 | handling configuration and creating configurables. | |
7 |
|
7 | |||
8 | The job of an :class:`Application` is to create the master configuration |
|
8 | The job of an :class:`Application` is to create the master configuration | |
9 | object and then create the configurable objects, passing the config to them. |
|
9 | object and then create the configurable objects, passing the config to them. | |
@@ -17,7 +17,7 b' Authors:' | |||||
17 | """ |
|
17 | """ | |
18 |
|
18 | |||
19 | #----------------------------------------------------------------------------- |
|
19 | #----------------------------------------------------------------------------- | |
20 |
# Copyright (C) 2008 |
|
20 | # Copyright (C) 2008 The IPython Development Team | |
21 | # |
|
21 | # | |
22 | # Distributed under the terms of the BSD License. The full license is in |
|
22 | # Distributed under the terms of the BSD License. The full license is in | |
23 | # the file COPYING, distributed as part of this software. |
|
23 | # the file COPYING, distributed as part of this software. | |
@@ -28,6 +28,7 b' Authors:' | |||||
28 | #----------------------------------------------------------------------------- |
|
28 | #----------------------------------------------------------------------------- | |
29 |
|
29 | |||
30 | import atexit |
|
30 | import atexit | |
|
31 | import errno | |||
31 | import glob |
|
32 | import glob | |
32 | import logging |
|
33 | import logging | |
33 | import os |
|
34 | import os | |
@@ -126,7 +127,7 b' class BaseIPythonApplication(Application):' | |||||
126 | get_ipython_package_dir(), u'config', u'profile', new |
|
127 | get_ipython_package_dir(), u'config', u'profile', new | |
127 | ) |
|
128 | ) | |
128 |
|
129 | |||
129 |
ipython_dir = Unicode( |
|
130 | ipython_dir = Unicode(config=True, | |
130 | help=""" |
|
131 | help=""" | |
131 | The name of the IPython directory. This directory is used for logging |
|
132 | The name of the IPython directory. This directory is used for logging | |
132 | configuration (through profiles), history storage, etc. The default |
|
133 | configuration (through profiles), history storage, etc. The default | |
@@ -134,6 +135,11 b' class BaseIPythonApplication(Application):' | |||||
134 | the environment variable IPYTHONDIR. |
|
135 | the environment variable IPYTHONDIR. | |
135 | """ |
|
136 | """ | |
136 | ) |
|
137 | ) | |
|
138 | def _ipython_dir_default(self): | |||
|
139 | d = get_ipython_dir() | |||
|
140 | self._ipython_dir_changed('ipython_dir', '', d) | |||
|
141 | return d | |||
|
142 | ||||
137 | _in_init_profile_dir = False |
|
143 | _in_init_profile_dir = False | |
138 | profile_dir = Instance(ProfileDir) |
|
144 | profile_dir = Instance(ProfileDir) | |
139 | def _profile_dir_default(self): |
|
145 | def _profile_dir_default(self): | |
@@ -179,10 +185,6 b' class BaseIPythonApplication(Application):' | |||||
179 | self.log.error("Current working directory doesn't exist.") |
|
185 | self.log.error("Current working directory doesn't exist.") | |
180 | raise |
|
186 | raise | |
181 |
|
187 | |||
182 | # ensure even default IPYTHONDIR exists |
|
|||
183 | if not os.path.exists(self.ipython_dir): |
|
|||
184 | self._ipython_dir_changed('ipython_dir', self.ipython_dir, self.ipython_dir) |
|
|||
185 |
|
||||
186 | #------------------------------------------------------------------------- |
|
188 | #------------------------------------------------------------------------- | |
187 | # Various stages of Application creation |
|
189 | # Various stages of Application creation | |
188 | #------------------------------------------------------------------------- |
|
190 | #------------------------------------------------------------------------- | |
@@ -214,9 +216,17 b' class BaseIPythonApplication(Application):' | |||||
214 | if not os.path.isdir(new): |
|
216 | if not os.path.isdir(new): | |
215 | os.makedirs(new, mode=0o777) |
|
217 | os.makedirs(new, mode=0o777) | |
216 | readme = os.path.join(new, 'README') |
|
218 | readme = os.path.join(new, 'README') | |
217 | if not os.path.exists(readme): |
|
219 | readme_src = os.path.join(get_ipython_package_dir(), u'config', u'profile', 'README') | |
218 | path = os.path.join(get_ipython_package_dir(), u'config', u'profile') |
|
220 | if not os.path.exists(readme) and os.path.exists(readme_src): | |
219 |
shutil.copy( |
|
221 | shutil.copy(readme_src, readme) | |
|
222 | for d in ('extensions', 'nbextensions'): | |||
|
223 | path = os.path.join(new, d) | |||
|
224 | if not os.path.exists(path): | |||
|
225 | try: | |||
|
226 | os.mkdir(path) | |||
|
227 | except OSError as e: | |||
|
228 | if e.errno != errno.EEXIST: | |||
|
229 | self.log.error("couldn't create path %s: %s", path, e) | |||
220 | self.log.debug("IPYTHONDIR set to: %s" % new) |
|
230 | self.log.debug("IPYTHONDIR set to: %s" % new) | |
221 |
|
231 | |||
222 | def load_config_file(self, suppress_errors=True): |
|
232 | def load_config_file(self, suppress_errors=True): |
General Comments 0
You need to be logged in to leave comments.
Login now