Show More
@@ -1,31 +1,11 b'' | |||||
1 | # encoding: utf-8 |
|
1 | # encoding: utf-8 | |
2 | """ |
|
2 | """A base class for objects that are configurable.""" | |
3 | A base class for objects that are configurable. |
|
|||
4 |
|
3 | |||
5 | Inheritance diagram: |
|
4 | # Copyright (c) IPython Development Team. | |
|
5 | # Distributed under the terms of the Modified BSD License. | |||
6 |
|
6 | |||
7 | .. inheritance-diagram:: IPython.config.configurable |
|
|||
8 | :parts: 3 |
|
|||
9 |
|
||||
10 | Authors: |
|
|||
11 |
|
||||
12 | * Brian Granger |
|
|||
13 | * Fernando Perez |
|
|||
14 | * Min RK |
|
|||
15 | """ |
|
|||
16 | from __future__ import print_function |
|
7 | from __future__ import print_function | |
17 |
|
8 | |||
18 | #----------------------------------------------------------------------------- |
|
|||
19 | # Copyright (C) 2008-2011 The IPython Development Team |
|
|||
20 | # |
|
|||
21 | # Distributed under the terms of the BSD License. The full license is in |
|
|||
22 | # the file COPYING, distributed as part of this software. |
|
|||
23 | #----------------------------------------------------------------------------- |
|
|||
24 |
|
||||
25 | #----------------------------------------------------------------------------- |
|
|||
26 | # Imports |
|
|||
27 | #----------------------------------------------------------------------------- |
|
|||
28 |
|
||||
29 | import logging |
|
9 | import logging | |
30 | from copy import deepcopy |
|
10 | from copy import deepcopy | |
31 |
|
11 | |||
@@ -375,16 +355,12 b' class LoggingConfigurable(Configurable):' | |||||
375 | """A parent class for Configurables that log. |
|
355 | """A parent class for Configurables that log. | |
376 |
|
356 | |||
377 | Subclasses have a log trait, and the default behavior |
|
357 | Subclasses have a log trait, and the default behavior | |
378 | is to get the logger from the currently running Application |
|
358 | is to get the logger from the currently running Application. | |
379 | via Application.instance().log. |
|
|||
380 | """ |
|
359 | """ | |
381 |
|
360 | |||
382 | log = Instance('logging.Logger') |
|
361 | log = Instance('logging.Logger') | |
383 | def _log_default(self): |
|
362 | def _log_default(self): | |
384 |
from IPython. |
|
363 | from IPython.utils import log | |
385 | if Application.initialized(): |
|
364 | return log.get_logger() | |
386 | return Application.instance().log |
|
|||
387 | else: |
|
|||
388 | return logging.getLogger() |
|
|||
389 |
|
365 | |||
390 |
|
366 |
@@ -1,27 +1,8 b'' | |||||
1 | """A simple configuration system. |
|
1 | # encoding: utf-8 | |
|
2 | """A simple configuration system.""" | |||
2 |
|
3 | |||
3 | Inheritance diagram: |
|
4 | # Copyright (c) IPython Development Team. | |
4 |
|
5 | # Distributed under the terms of the Modified BSD License. | ||
5 | .. inheritance-diagram:: IPython.config.loader |
|
|||
6 | :parts: 3 |
|
|||
7 |
|
||||
8 | Authors |
|
|||
9 | ------- |
|
|||
10 | * Brian Granger |
|
|||
11 | * Fernando Perez |
|
|||
12 | * Min RK |
|
|||
13 | """ |
|
|||
14 |
|
||||
15 | #----------------------------------------------------------------------------- |
|
|||
16 | # Copyright (C) 2008-2011 The IPython Development Team |
|
|||
17 | # |
|
|||
18 | # Distributed under the terms of the BSD License. The full license is in |
|
|||
19 | # the file COPYING, distributed as part of this software. |
|
|||
20 | #----------------------------------------------------------------------------- |
|
|||
21 |
|
||||
22 | #----------------------------------------------------------------------------- |
|
|||
23 | # Imports |
|
|||
24 | #----------------------------------------------------------------------------- |
|
|||
25 |
|
6 | |||
26 | import argparse |
|
7 | import argparse | |
27 | import copy |
|
8 | import copy | |
@@ -308,11 +289,8 b' class ConfigLoader(object):' | |||||
308 | """ |
|
289 | """ | |
309 |
|
290 | |||
310 | def _log_default(self): |
|
291 | def _log_default(self): | |
311 |
from IPython. |
|
292 | from IPython.utils.log import get_logger | |
312 | if Application.initialized(): |
|
293 | return get_logger() | |
313 | return Application.instance().log |
|
|||
314 | else: |
|
|||
315 | return logging.getLogger() |
|
|||
316 |
|
294 | |||
317 | def __init__(self, log=None): |
|
295 | def __init__(self, log=None): | |
318 | """A base class for config loaders. |
|
296 | """A base class for config loaders. |
@@ -1,21 +1,7 b'' | |||||
1 | """Base Tornado handlers for the notebook. |
|
1 | """Base Tornado handlers for the notebook.""" | |
2 |
|
||||
3 | Authors: |
|
|||
4 |
|
||||
5 | * Brian Granger |
|
|||
6 | """ |
|
|||
7 |
|
||||
8 | #----------------------------------------------------------------------------- |
|
|||
9 | # Copyright (C) 2011 The IPython Development Team |
|
|||
10 | # |
|
|||
11 | # Distributed under the terms of the BSD License. The full license is in |
|
|||
12 | # the file COPYING, distributed as part of this software. |
|
|||
13 | #----------------------------------------------------------------------------- |
|
|||
14 |
|
||||
15 | #----------------------------------------------------------------------------- |
|
|||
16 | # Imports |
|
|||
17 | #----------------------------------------------------------------------------- |
|
|||
18 |
|
2 | |||
|
3 | # Copyright (c) IPython Development Team. | |||
|
4 | # Distributed under the terms of the Modified BSD License. | |||
19 |
|
5 | |||
20 | import functools |
|
6 | import functools | |
21 | import json |
|
7 | import json |
@@ -1,21 +1,4 b'' | |||||
1 | """The official API for working with notebooks in the current format version. |
|
1 | """The official API for working with notebooks in the current format version.""" | |
2 |
|
||||
3 | Authors: |
|
|||
4 |
|
||||
5 | * Brian Granger |
|
|||
6 | * Jonathan Frederic |
|
|||
7 | """ |
|
|||
8 |
|
||||
9 | #----------------------------------------------------------------------------- |
|
|||
10 | # Copyright (C) 2008-2011 The IPython Development Team |
|
|||
11 | # |
|
|||
12 | # Distributed under the terms of the BSD License. The full license is in |
|
|||
13 | # the file COPYING, distributed as part of this software. |
|
|||
14 | #----------------------------------------------------------------------------- |
|
|||
15 |
|
||||
16 | #----------------------------------------------------------------------------- |
|
|||
17 | # Imports |
|
|||
18 | #----------------------------------------------------------------------------- |
|
|||
19 |
|
2 | |||
20 | from __future__ import print_function |
|
3 | from __future__ import print_function | |
21 |
|
4 | |||
@@ -37,12 +20,8 b' from .reader import versions' | |||||
37 | from .convert import convert |
|
20 | from .convert import convert | |
38 | from .validator import validate |
|
21 | from .validator import validate | |
39 |
|
22 | |||
40 | import logging |
|
23 | from IPython.utils.log import get_logger | |
41 | logger = logging.getLogger('NotebookApp') |
|
|||
42 |
|
24 | |||
43 | #----------------------------------------------------------------------------- |
|
|||
44 | # Code |
|
|||
45 | #----------------------------------------------------------------------------- |
|
|||
46 |
|
25 | |||
47 | current_nbformat = nbformat |
|
26 | current_nbformat = nbformat | |
48 | current_nbformat_minor = nbformat_minor |
|
27 | current_nbformat_minor = nbformat_minor | |
@@ -88,7 +67,7 b' def reads_json(nbjson, **kwargs):' | |||||
88 | nb_current = convert(nb, current_nbformat) |
|
67 | nb_current = convert(nb, current_nbformat) | |
89 | errors = validate(nb_current) |
|
68 | errors = validate(nb_current) | |
90 | if errors: |
|
69 | if errors: | |
91 | logger.error( |
|
70 | get_logger().error( | |
92 | "Notebook JSON is invalid (%d errors detected during read)", |
|
71 | "Notebook JSON is invalid (%d errors detected during read)", | |
93 | len(errors)) |
|
72 | len(errors)) | |
94 | return nb_current |
|
73 | return nb_current | |
@@ -101,7 +80,7 b' def writes_json(nb, **kwargs):' | |||||
101 | """ |
|
80 | """ | |
102 | errors = validate(nb) |
|
81 | errors = validate(nb) | |
103 | if errors: |
|
82 | if errors: | |
104 | logger.error( |
|
83 | get_logger().error( | |
105 | "Notebook JSON is invalid (%d errors detected during write)", |
|
84 | "Notebook JSON is invalid (%d errors detected during write)", | |
106 | len(errors)) |
|
85 | len(errors)) | |
107 | nbjson = versions[current_nbformat].writes_json(nb, **kwargs) |
|
86 | nbjson = versions[current_nbformat].writes_json(nb, **kwargs) |
@@ -3,21 +3,10 b'' | |||||
3 | The Pure ZMQ scheduler does not allow routing schemes other than LRU, |
|
3 | The Pure ZMQ scheduler does not allow routing schemes other than LRU, | |
4 | nor does it check msg_id DAG dependencies. For those, a slightly slower |
|
4 | nor does it check msg_id DAG dependencies. For those, a slightly slower | |
5 | Python Scheduler exists. |
|
5 | Python Scheduler exists. | |
6 |
|
||||
7 | Authors: |
|
|||
8 |
|
||||
9 | * Min RK |
|
|||
10 | """ |
|
6 | """ | |
11 | #----------------------------------------------------------------------------- |
|
|||
12 | # Copyright (C) 2010-2011 The IPython Development Team |
|
|||
13 | # |
|
|||
14 | # Distributed under the terms of the BSD License. The full license is in |
|
|||
15 | # the file COPYING, distributed as part of this software. |
|
|||
16 | #----------------------------------------------------------------------------- |
|
|||
17 |
|
7 | |||
18 | #---------------------------------------------------------------------- |
|
8 | # Copyright (c) IPython Development Team. | |
19 | # Imports |
|
9 | # Distributed under the terms of the Modified BSD License. | |
20 | #---------------------------------------------------------------------- |
|
|||
21 |
|
10 | |||
22 | import logging |
|
11 | import logging | |
23 | import sys |
|
12 | import sys |
@@ -27,6 +27,7 b' except:' | |||||
27 | import zmq |
|
27 | import zmq | |
28 | from zmq.log import handlers |
|
28 | from zmq.log import handlers | |
29 |
|
29 | |||
|
30 | from IPython.utils.log import get_logger | |||
30 | from IPython.external.decorator import decorator |
|
31 | from IPython.external.decorator import decorator | |
31 |
|
32 | |||
32 | from IPython.config.application import Application |
|
33 | from IPython.config.application import Application | |
@@ -296,7 +297,7 b' def select_random_ports(n):' | |||||
296 | def signal_children(children): |
|
297 | def signal_children(children): | |
297 | """Relay interupt/term signals to children, for more solid process cleanup.""" |
|
298 | """Relay interupt/term signals to children, for more solid process cleanup.""" | |
298 | def terminate_children(sig, frame): |
|
299 | def terminate_children(sig, frame): | |
299 | log = Application.instance().log |
|
300 | log = get_logger() | |
300 | log.critical("Got signal %i, terminating children..."%sig) |
|
301 | log.critical("Got signal %i, terminating children..."%sig) | |
301 | for child in children: |
|
302 | for child in children: | |
302 | child.terminate() |
|
303 | child.terminate() |
@@ -20,6 +20,7 b' from .importstring import import_item' | |||||
20 | from .py3compat import string_types, iteritems |
|
20 | from .py3compat import string_types, iteritems | |
21 |
|
21 | |||
22 | from IPython.config import Application |
|
22 | from IPython.config import Application | |
|
23 | from IPython.utils.log import get_logger | |||
23 |
|
24 | |||
24 | if py3compat.PY3: |
|
25 | if py3compat.PY3: | |
25 | buffer = memoryview |
|
26 | buffer = memoryview | |
@@ -276,25 +277,11 b' def CannedBuffer(CannedBytes):' | |||||
276 | # Functions |
|
277 | # Functions | |
277 | #------------------------------------------------------------------------------- |
|
278 | #------------------------------------------------------------------------------- | |
278 |
|
279 | |||
279 | def _logger(): |
|
|||
280 | """get the logger for the current Application |
|
|||
281 |
|
||||
282 | the root logger will be used if no Application is running |
|
|||
283 | """ |
|
|||
284 | if Application.initialized(): |
|
|||
285 | logger = Application.instance().log |
|
|||
286 | else: |
|
|||
287 | logger = logging.getLogger() |
|
|||
288 | if not logger.handlers: |
|
|||
289 | logging.basicConfig() |
|
|||
290 |
|
||||
291 | return logger |
|
|||
292 |
|
||||
293 | def _import_mapping(mapping, original=None): |
|
280 | def _import_mapping(mapping, original=None): | |
294 | """import any string-keys in a type mapping |
|
281 | """import any string-keys in a type mapping | |
295 |
|
282 | |||
296 | """ |
|
283 | """ | |
297 | log = _logger() |
|
284 | log = get_logger() | |
298 | log.debug("Importing canning map") |
|
285 | log.debug("Importing canning map") | |
299 | for key,value in list(mapping.items()): |
|
286 | for key,value in list(mapping.items()): | |
300 | if isinstance(key, string_types): |
|
287 | if isinstance(key, string_types): |
General Comments 0
You need to be logged in to leave comments.
Login now