Show More
@@ -1008,6 +1008,16 b' def get_security_dir():' | |||||
1008 | os.chmod(security_dir, 0700) |
|
1008 | os.chmod(security_dir, 0700) | |
1009 | return security_dir |
|
1009 | return security_dir | |
1010 |
|
1010 | |||
|
1011 | def get_log_dir(): | |||
|
1012 | """Get the IPython log directory. | |||
|
1013 | ||||
|
1014 | If the log directory does not exist, it is created. | |||
|
1015 | """ | |||
|
1016 | log_dir = os.path.join(get_ipython_dir(), 'log') | |||
|
1017 | if not os.path.isdir(log_dir): | |||
|
1018 | os.mkdir(log_dir, 0777) | |||
|
1019 | return log_dir | |||
|
1020 | ||||
1011 | #**************************************************************************** |
|
1021 | #**************************************************************************** | |
1012 | # strings and text |
|
1022 | # strings and text | |
1013 |
|
1023 |
@@ -15,10 +15,9 b' if they need blocking clients or in `asyncclient.py` if they want asynchronous,' | |||||
15 | deferred/Twisted using clients. |
|
15 | deferred/Twisted using clients. | |
16 | """ |
|
16 | """ | |
17 | __docformat__ = "restructuredtext en" |
|
17 | __docformat__ = "restructuredtext en" | |
18 |
#----------------------------------------------------------------------------- |
|
18 | #----------------------------------------------------------------------------- | |
19 | # Copyright (C) 2008 The IPython Development Team |
|
19 | # Copyright (C) 2008 The IPython Development Team | |
20 | # |
|
20 | # | |
21 | # Distributed under the terms of the BSD License. The full license is in |
|
21 | # Distributed under the terms of the BSD License. The full license is in | |
22 | # the file COPYING, distributed as part of this software. |
|
22 | # the file COPYING, distributed as part of this software. | |
23 |
#----------------------------------------------------------------------------- |
|
23 | #----------------------------------------------------------------------------- No newline at end of file | |
24 | No newline at end of file |
|
@@ -15,6 +15,7 b' __docformat__ = "restructuredtext en"' | |||||
15 | # Imports |
|
15 | # Imports | |
16 | #------------------------------------------------------------------------------- |
|
16 | #------------------------------------------------------------------------------- | |
17 |
|
17 | |||
|
18 | import os, sys | |||
18 | from os.path import join as pjoin |
|
19 | from os.path import join as pjoin | |
19 |
|
20 | |||
20 | from IPython.external.configobj import ConfigObj |
|
21 | from IPython.external.configobj import ConfigObj | |
@@ -23,6 +24,7 b' from IPython.genutils import get_ipython_dir, get_security_dir' | |||||
23 |
|
24 | |||
24 | default_kernel_config = ConfigObj() |
|
25 | default_kernel_config = ConfigObj() | |
25 |
|
26 | |||
|
27 | # This will raise OSError if ipythondir doesn't exist. | |||
26 | security_dir = get_security_dir() |
|
28 | security_dir = get_security_dir() | |
27 |
|
29 | |||
28 | #------------------------------------------------------------------------------- |
|
30 | #------------------------------------------------------------------------------- |
@@ -29,8 +29,21 b' from twisted.python import failure, log' | |||||
29 |
|
29 | |||
30 | from IPython.external import argparse |
|
30 | from IPython.external import argparse | |
31 | from IPython.external import Itpl |
|
31 | from IPython.external import Itpl | |
32 |
from IPython.genutils import get_ipython_dir, |
|
32 | from IPython.genutils import get_ipython_dir, get_log_dir, get_security_dir | |
|
33 | from IPython.genutils import num_cpus | |||
33 | from IPython.kernel.fcutil import have_crypto |
|
34 | from IPython.kernel.fcutil import have_crypto | |
|
35 | ||||
|
36 | # Create various ipython directories if they don't exist. | |||
|
37 | # This must be done before IPython.kernel.config is imported. | |||
|
38 | from IPython.iplib import user_setup | |||
|
39 | if os.name == 'posix': | |||
|
40 | rc_suffix = '' | |||
|
41 | else: | |||
|
42 | rc_suffix = '.ini' | |||
|
43 | user_setup(get_ipython_dir(), rc_suffix, mode='install', interactive=False) | |||
|
44 | get_log_dir() | |||
|
45 | get_security_dir() | |||
|
46 | ||||
34 | from IPython.kernel.config import config_manager as kernel_config_manager |
|
47 | from IPython.kernel.config import config_manager as kernel_config_manager | |
35 | from IPython.kernel.error import SecurityError, FileTimeoutError |
|
48 | from IPython.kernel.error import SecurityError, FileTimeoutError | |
36 | from IPython.kernel.fcutil import have_crypto |
|
49 | from IPython.kernel.fcutil import have_crypto |
@@ -38,6 +38,18 b' from IPython.kernel.error import SecurityError' | |||||
38 | from IPython.kernel import controllerservice |
|
38 | from IPython.kernel import controllerservice | |
39 | from IPython.kernel.fcutil import check_furl_file_security |
|
39 | from IPython.kernel.fcutil import check_furl_file_security | |
40 |
|
40 | |||
|
41 | # Create various ipython directories if they don't exist. | |||
|
42 | # This must be done before IPython.kernel.config is imported. | |||
|
43 | from IPython.iplib import user_setup | |||
|
44 | from IPython.genutils import get_ipython_dir, get_log_dir, get_security_dir | |||
|
45 | if os.name == 'posix': | |||
|
46 | rc_suffix = '' | |||
|
47 | else: | |||
|
48 | rc_suffix = '.ini' | |||
|
49 | user_setup(get_ipython_dir(), rc_suffix, mode='install', interactive=False) | |||
|
50 | get_log_dir() | |||
|
51 | get_security_dir() | |||
|
52 | ||||
41 | from IPython.kernel.config import config_manager as kernel_config_manager |
|
53 | from IPython.kernel.config import config_manager as kernel_config_manager | |
42 | from IPython.config.cutils import import_item |
|
54 | from IPython.config.cutils import import_item | |
43 |
|
55 | |||
@@ -116,7 +128,6 b' def make_client_service(controller_service, config):' | |||||
116 | # appears to other processes, the buffer has the flushed |
|
128 | # appears to other processes, the buffer has the flushed | |
117 | # and the file has been closed |
|
129 | # and the file has been closed | |
118 | temp_furl_file = get_temp_furlfile(furl_file) |
|
130 | temp_furl_file = get_temp_furlfile(furl_file) | |
119 | log.msg(temp_furl_file) |
|
|||
120 | client_tub.registerReference(ref, furlFile=temp_furl_file) |
|
131 | client_tub.registerReference(ref, furlFile=temp_furl_file) | |
121 | os.rename(temp_furl_file, furl_file) |
|
132 | os.rename(temp_furl_file, furl_file) | |
122 |
|
133 | |||
@@ -169,7 +180,6 b' def make_engine_service(controller_service, config):' | |||||
169 | # appears to other processes, the buffer has the flushed |
|
180 | # appears to other processes, the buffer has the flushed | |
170 | # and the file has been closed |
|
181 | # and the file has been closed | |
171 | temp_furl_file = get_temp_furlfile(furl_file) |
|
182 | temp_furl_file = get_temp_furlfile(furl_file) | |
172 | log.msg(temp_furl_file) |
|
|||
173 | engine_tub.registerReference(ref, furlFile=temp_furl_file) |
|
183 | engine_tub.registerReference(ref, furlFile=temp_furl_file) | |
174 | os.rename(temp_furl_file, furl_file) |
|
184 | os.rename(temp_furl_file, furl_file) | |
175 |
|
185 | |||
@@ -342,12 +352,6 b' def init_config():' | |||||
342 | help="log file name (default is stdout)" |
|
352 | help="log file name (default is stdout)" | |
343 | ) |
|
353 | ) | |
344 | parser.add_option( |
|
354 | parser.add_option( | |
345 | "--ipythondir", |
|
|||
346 | type="string", |
|
|||
347 | dest="ipythondir", |
|
|||
348 | help="look for config files and profiles in this directory" |
|
|||
349 | ) |
|
|||
350 | parser.add_option( |
|
|||
351 | "-r", |
|
355 | "-r", | |
352 | action="store_true", |
|
356 | action="store_true", | |
353 | dest="reuse_furls", |
|
357 | dest="reuse_furls", | |
@@ -356,7 +360,6 b' def init_config():' | |||||
356 |
|
360 | |||
357 | (options, args) = parser.parse_args() |
|
361 | (options, args) = parser.parse_args() | |
358 |
|
362 | |||
359 | kernel_config_manager.update_config_obj_from_default_file(options.ipythondir) |
|
|||
360 | config = kernel_config_manager.get_config_obj() |
|
363 | config = kernel_config_manager.get_config_obj() | |
361 |
|
364 | |||
362 | # Update with command line options |
|
365 | # Update with command line options |
@@ -33,6 +33,19 b' from IPython.kernel.fcutil import Tub, UnauthenticatedTub' | |||||
33 | from IPython.kernel.core.config import config_manager as core_config_manager |
|
33 | from IPython.kernel.core.config import config_manager as core_config_manager | |
34 | from IPython.config.cutils import import_item |
|
34 | from IPython.config.cutils import import_item | |
35 | from IPython.kernel.engineservice import EngineService |
|
35 | from IPython.kernel.engineservice import EngineService | |
|
36 | ||||
|
37 | # Create various ipython directories if they don't exist. | |||
|
38 | # This must be done before IPython.kernel.config is imported. | |||
|
39 | from IPython.iplib import user_setup | |||
|
40 | from IPython.genutils import get_ipython_dir, get_log_dir, get_security_dir | |||
|
41 | if os.name == 'posix': | |||
|
42 | rc_suffix = '' | |||
|
43 | else: | |||
|
44 | rc_suffix = '.ini' | |||
|
45 | user_setup(get_ipython_dir(), rc_suffix, mode='install', interactive=False) | |||
|
46 | get_log_dir() | |||
|
47 | get_security_dir() | |||
|
48 | ||||
36 | from IPython.kernel.config import config_manager as kernel_config_manager |
|
49 | from IPython.kernel.config import config_manager as kernel_config_manager | |
37 | from IPython.kernel.engineconnector import EngineConnector |
|
50 | from IPython.kernel.engineconnector import EngineConnector | |
38 |
|
51 | |||
@@ -148,18 +161,9 b' def init_config():' | |||||
148 | dest="logfile", |
|
161 | dest="logfile", | |
149 | help="log file name (default is stdout)" |
|
162 | help="log file name (default is stdout)" | |
150 | ) |
|
163 | ) | |
151 | parser.add_option( |
|
|||
152 | "--ipythondir", |
|
|||
153 | type="string", |
|
|||
154 | dest="ipythondir", |
|
|||
155 | help="look for config files and profiles in this directory" |
|
|||
156 | ) |
|
|||
157 |
|
164 | |||
158 | (options, args) = parser.parse_args() |
|
165 | (options, args) = parser.parse_args() | |
159 |
|
166 | |||
160 | kernel_config_manager.update_config_obj_from_default_file(options.ipythondir) |
|
|||
161 | core_config_manager.update_config_obj_from_default_file(options.ipythondir) |
|
|||
162 |
|
||||
163 | kernel_config = kernel_config_manager.get_config_obj() |
|
167 | kernel_config = kernel_config_manager.get_config_obj() | |
164 | # Now override with command line options |
|
168 | # Now override with command line options | |
165 | if options.furl_file is not None: |
|
169 | if options.furl_file is not None: |
@@ -210,7 +210,6 b' def test_get_home_dir_7():' | |||||
210 | home_dir = genutils.get_home_dir() |
|
210 | home_dir = genutils.get_home_dir() | |
211 | nt.assert_equal(home_dir, abspath(HOME_TEST_DIR)) |
|
211 | nt.assert_equal(home_dir, abspath(HOME_TEST_DIR)) | |
212 |
|
212 | |||
213 |
|
||||
214 | # |
|
213 | # | |
215 | # Tests for get_ipython_dir |
|
214 | # Tests for get_ipython_dir | |
216 | # |
|
215 | # | |
@@ -239,7 +238,6 b' def test_get_ipython_dir_3():' | |||||
239 | ipdir = genutils.get_ipython_dir() |
|
238 | ipdir = genutils.get_ipython_dir() | |
240 | nt.assert_equal(ipdir, os.path.abspath(os.path.join("someplace", "_ipython"))) |
|
239 | nt.assert_equal(ipdir, os.path.abspath(os.path.join("someplace", "_ipython"))) | |
241 |
|
240 | |||
242 |
|
||||
243 | # |
|
241 | # | |
244 | # Tests for get_security_dir |
|
242 | # Tests for get_security_dir | |
245 | # |
|
243 | # | |
@@ -249,6 +247,14 b' def test_get_security_dir():' | |||||
249 | """Testcase to see if we can call get_security_dir without Exceptions.""" |
|
247 | """Testcase to see if we can call get_security_dir without Exceptions.""" | |
250 | sdir = genutils.get_security_dir() |
|
248 | sdir = genutils.get_security_dir() | |
251 |
|
249 | |||
|
250 | # | |||
|
251 | # Tests for get_log_dir | |||
|
252 | # | |||
|
253 | ||||
|
254 | @with_enivronment | |||
|
255 | def test_get_log_dir(): | |||
|
256 | """Testcase to see if we can call get_log_dir without Exceptions.""" | |||
|
257 | sdir = genutils.get_log_dir() | |||
252 |
|
258 | |||
253 | # |
|
259 | # | |
254 | # Tests for popkey |
|
260 | # Tests for popkey |
General Comments 0
You need to be logged in to leave comments.
Login now