Permalink
Browse files

Merge branch 'newapp'

closes gh-503
closes gh-454
closes gh-79
closes gh-456
closes gh-451
  • Loading branch information...
2 parents ec698f9 + 2b56c84 commit fbd5ae94cfd63c1e604b9c0b4259cb6749db4ae4 @minrk minrk committed Jun 21, 2011
Showing with 5,895 additions and 5,817 deletions.
  1. +222 −59 IPython/config/application.py
  2. +110 −20 IPython/config/configurable.py
  3. 0 IPython/config/default/__init__.py
  4. +0 −241 IPython/config/default/ipcluster_config.py
  5. +0 −180 IPython/config/default/ipcontroller_config.py
  6. +0 −85 IPython/config/default/ipengine_config.py
  7. +0 −165 IPython/config/default/ipython_config.py
  8. +54 −14 IPython/config/loader.py
  9. +5 −0 IPython/config/profile/README
  10. +9 −8 IPython/config/profile/{ipython_config_cluster.py → cluster/ipython_config.py}
  11. +0 −20 IPython/config/profile/ipython_config_numeric.py
  12. +6 −4 IPython/config/profile/{ipython_config_math.py → math/ipython_config.py}
  13. +7 −6 IPython/config/profile/{ipython_config_pylab.py → pylab/ipython_config.py}
  14. +5 −4 IPython/config/profile/{ipython_config_pysh.py → pysh/ipython_config.py}
  15. +8 −7 IPython/config/profile/{ipython_config_sympy.py → sympy/ipython_config.py}
  16. +36 −6 IPython/config/tests/test_application.py
  17. +2 −0 IPython/config/tests/test_configurable.py
  18. +7 −0 IPython/config/tests/test_loader.py
  19. +219 −397 IPython/core/application.py
  20. +3 −6 IPython/core/history.py
  21. +22 −11 IPython/core/interactiveshell.py
  22. +14 −28 IPython/core/magic.py
  23. +219 −0 IPython/core/profileapp.py
  24. +206 −0 IPython/core/profiledir.py
  25. +244 −0 IPython/core/shellapp.py
  26. +9 −31 IPython/core/tests/test_application.py
  27. +15 −9 IPython/extensions/parallelmagic.py
  28. +4 −4 IPython/frontend/qt/base_frontend_mixin.py
  29. +64 −33 IPython/frontend/qt/console/console_widget.py
  30. +6 −5 IPython/frontend/qt/console/frontend_widget.py
  31. +51 −33 IPython/frontend/qt/console/ipython_widget.py
  32. +0 −277 IPython/frontend/qt/console/ipythonqt.py
  33. +421 −0 IPython/frontend/qt/console/qtconsoleapp.py
  34. +16 −16 IPython/frontend/qt/kernelmanager.py
  35. +39 −13 IPython/frontend/terminal/interactiveshell.py
  36. +193 −502 IPython/frontend/terminal/ipapp.py
  37. +1 −3 IPython/lib/irunner.py
  38. +44 −32 IPython/lib/pylabtools.py
  39. +2 −2 IPython/lib/tests/test_pylabtools.py
  40. +6 −1 IPython/parallel/__init__.py
  41. +267 −0 IPython/parallel/apps/baseapp.py
  42. +0 −566 IPython/parallel/apps/clusterdir.py
  43. +291 −462 IPython/parallel/apps/ipclusterapp.py
  44. +242 −267 IPython/parallel/apps/ipcontrollerapp.py
  45. +137 −164 IPython/parallel/apps/ipengineapp.py
  46. +35 −66 IPython/parallel/apps/iploggerapp.py
  47. +265 −198 IPython/parallel/apps/launcher.py
  48. +30 −13 IPython/parallel/apps/logwatcher.py
  49. +10 −4 IPython/parallel/apps/win32support.py
  50. +46 −40 IPython/parallel/apps/winhpcjob.py
  51. +6 −1 IPython/parallel/client/asyncresult.py
  52. +74 −56 IPython/parallel/client/client.py
  53. +8 −1 IPython/parallel/client/map.py
  54. +8 −2 IPython/parallel/client/remotefunction.py
  55. +7 −2 IPython/parallel/client/view.py
  56. +0 −116 IPython/parallel/controller/controller.py
  57. +6 −1 IPython/parallel/controller/dependency.py
  58. +10 −5 IPython/parallel/controller/dictdb.py
  59. +12 −6 IPython/parallel/controller/heartmonitor.py
  60. +131 −125 IPython/parallel/controller/hub.py
  61. +22 −6 IPython/parallel/controller/mongodb.py
  62. +52 −25 IPython/parallel/controller/scheduler.py
  63. +91 −26 IPython/parallel/controller/sqlitedb.py
  64. +24 −10 IPython/parallel/engine/engine.py
  65. +8 −3 IPython/parallel/engine/kernelstarter.py
  66. +20 −22 IPython/parallel/engine/streamkernel.py
  67. +8 −2 IPython/parallel/error.py
  68. +23 −98 IPython/parallel/factory.py
  69. +0 −419 IPython/parallel/streamsession.py
  70. +3 −3 IPython/parallel/tests/__init__.py
  71. +6 −1 IPython/parallel/tests/clienttest.py
  72. +6 −1 IPython/parallel/tests/test_asyncresult.py
  73. +6 −1 IPython/parallel/tests/test_client.py
  74. +11 −3 IPython/parallel/tests/test_db.py
  75. +6 −1 IPython/parallel/tests/test_dependency.py
  76. +6 −1 IPython/parallel/tests/test_lbview.py
  77. +6 −1 IPython/parallel/tests/test_mongodb.py
  78. +6 −1 IPython/parallel/tests/test_newserialized.py
  79. +7 −1 IPython/parallel/tests/test_view.py
  80. +8 −41 IPython/parallel/util.py
  81. +0 −6 IPython/scripts/ipython-qtconsole
  82. +6 −3 IPython/testing/tools.py
  83. +26 −0 IPython/utils/daemonize.py
  84. +67 −0 IPython/utils/jsonutil.py
  85. +13 −6 IPython/utils/path.py
  86. +119 −3 IPython/utils/text.py
  87. +2 −2 IPython/zmq/__init__.py
  88. +8 −8 IPython/zmq/blockingkernelmanager.py
  89. +29 −168 IPython/zmq/entry_point.py
  90. +147 −163 IPython/zmq/ipkernel.py
  91. +215 −0 IPython/zmq/kernelapp.py
  92. +57 −49 IPython/zmq/kernelmanager.py
  93. +13 −0 IPython/zmq/logtopics.rst
  94. +45 −83 IPython/zmq/pykernel.py
  95. +47 −11 IPython/zmq/pylab/backend_inline.py
  96. +520 −77 IPython/zmq/session.py
  97. +2 −2 IPython/zmq/tests/test_message_spec.py
  98. +8 −8 IPython/{parallel/tests/test_streamsession.py → zmq/tests/test_session.py}
  99. +13 −8 docs/examples/core/appconfig.py
  100. +1 −1 docs/source/config/extensions.txt
  101. +40 −29 docs/source/config/ipython.txt
  102. +171 −34 docs/source/config/overview.txt
  103. +0 −1 docs/source/development/index.txt
  104. +3 −4 docs/source/install/install.txt
  105. +23 −20 docs/source/interactive/qtconsole.txt
  106. +48 −47 docs/source/interactive/reference.txt
  107. +1 −1 docs/source/interactive/tutorial.txt
  108. +1 −1 docs/source/parallel/parallel_intro.txt
  109. +5 −5 docs/source/parallel/parallel_mpi.txt
  110. +1 −1 docs/source/parallel/parallel_multiengine.txt
  111. +49 −51 docs/source/parallel/parallel_process.txt
  112. +23 −23 docs/source/parallel/parallel_security.txt
  113. +5 −5 docs/source/parallel/parallel_task.txt
  114. +6 −6 docs/source/parallel/parallel_winhpc.txt
  115. +1 −1 setup.py
  116. +4 −5 setupbase.py
  117. +3 −2 setupext/setupext.py

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -7,10 +7,11 @@
* Brian Granger
* Fernando Perez
+* Min RK
"""
#-----------------------------------------------------------------------------
-# Copyright (C) 2008-2010 The IPython Development Team
+# Copyright (C) 2008-2011 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
@@ -20,12 +21,12 @@
# Imports
#-----------------------------------------------------------------------------
-from copy import deepcopy
import datetime
+from copy import deepcopy
from loader import Config
from IPython.utils.traitlets import HasTraits, Instance
-from IPython.utils.text import indent
+from IPython.utils.text import indent, wrap_paragraphs
#-----------------------------------------------------------------------------
@@ -44,14 +45,13 @@ class MultipleInstanceError(ConfigurableError):
# Configurable implementation
#-----------------------------------------------------------------------------
-
class Configurable(HasTraits):
config = Instance(Config,(),{})
created = None
def __init__(self, **kwargs):
- """Create a conigurable given a config config.
+ """Create a configurable given a config config.
Parameters
----------
@@ -146,18 +146,72 @@ def class_get_help(cls):
final_help = []
final_help.append(u'%s options' % cls.__name__)
final_help.append(len(final_help[0])*u'-')
- for k, v in cls_traits.items():
- help = v.get_metadata('help')
- header = "%s.%s : %s" % (cls.__name__, k, v.__class__.__name__)
- final_help.append(header)
- if help is not None:
- final_help.append(indent(help))
+ for k,v in cls.class_traits(config=True).iteritems():
+ help = cls.class_get_trait_help(v)
+ final_help.append(help)
return '\n'.join(final_help)
+
+ @classmethod
+ def class_get_trait_help(cls, trait):
+ """Get the help string for a single trait."""
+ lines = []
+ header = "%s.%s : %s" % (cls.__name__, trait.name, trait.__class__.__name__)
+ lines.append(header)
+ try:
+ dvr = repr(trait.get_default_value())
+ except Exception:
+ dvr = None # ignore defaults we can't construct
+ if dvr is not None:
+ if len(dvr) > 64:
+ dvr = dvr[:61]+'...'
+ lines.append(indent('Default: %s'%dvr, 4))
+ if 'Enum' in trait.__class__.__name__:
+ # include Enum choices
+ lines.append(indent('Choices: %r'%(trait.values,)))
+
+ help = trait.get_metadata('help')
+ if help is not None:
+ help = '\n'.join(wrap_paragraphs(help, 76))
+ lines.append(indent(help, 4))
+ return '\n'.join(lines)
@classmethod
def class_print_help(cls):
+ """Get the help string for a single trait and print it."""
print cls.class_get_help()
+ @classmethod
+ def class_config_section(cls):
+ """Get the config class config section"""
+ def c(s):
+ """return a commented, wrapped block."""
+ s = '\n\n'.join(wrap_paragraphs(s, 78))
+
+ return '# ' + s.replace('\n', '\n# ')
+
+ # section header
+ breaker = '#' + '-'*78
+ s = "# %s configuration"%cls.__name__
+ lines = [breaker, s, breaker, '']
+ # get the description trait
+ desc = cls.class_traits().get('description')
+ if desc:
+ desc = desc.default_value
+ else:
+ # no description trait, use __doc__
+ desc = getattr(cls, '__doc__', '')
+ if desc:
+ lines.append(c(desc))
+ lines.append('')
+
+ for name,trait in cls.class_traits(config=True).iteritems():
+ help = trait.get_metadata('help') or ''
+ lines.append(c(help))
+ lines.append('# c.%s.%s = %r'%(cls.__name__, name, trait.get_default_value()))
+ lines.append('')
+ return '\n'.join(lines)
+
+
class SingletonConfigurable(Configurable):
"""A configurable that only allows one instance.
@@ -168,7 +222,32 @@ class SingletonConfigurable(Configurable):
"""
_instance = None
-
+
+ @classmethod
+ def _walk_mro(cls):
+ """Walk the cls.mro() for parent classes that are also singletons
+
+ For use in instance()
+ """
+
+ for subclass in cls.mro():
+ if issubclass(cls, subclass) and \
+ issubclass(subclass, SingletonConfigurable) and \
+ subclass != SingletonConfigurable:
+ yield subclass
+
+ @classmethod
+ def clear_instance(cls):
+ """unset _instance for this class and singleton parents.
+ """
+ if not cls.initialized():
+ return
+ for subclass in cls._walk_mro():
+ if isinstance(subclass._instance, cls):
+ # only clear instances that are instances
+ # of the calling class
+ subclass._instance = None
+
@classmethod
def instance(cls, *args, **kwargs):
"""Returns a global instance of this class.
@@ -202,14 +281,10 @@ def instance(cls, *args, **kwargs):
if cls._instance is None:
inst = cls(*args, **kwargs)
# Now make sure that the instance will also be returned by
- # the subclasses instance attribute.
- for subclass in cls.mro():
- if issubclass(cls, subclass) and \
- issubclass(subclass, SingletonConfigurable) and \
- subclass != SingletonConfigurable:
- subclass._instance = inst
- else:
- break
+ # parent classes' _instance attribute.
+ for subclass in cls._walk_mro():
+ subclass._instance = inst
+
if isinstance(cls._instance, cls):
return cls._instance
else:
@@ -223,3 +298,18 @@ def initialized(cls):
"""Has an instance been created?"""
return hasattr(cls, "_instance") and cls._instance is not None
+
+class LoggingConfigurable(Configurable):
+ """A parent class for Configurables that log.
+
+ Subclasses have a log trait, and the default behavior
+ is to get the logger from the currently running Application
+ via Application.instance().log.
+ """
+
+ log = Instance('logging.Logger')
+ def _log_default(self):
+ from IPython.config.application import Application
+ return Application.instance().log
+
+
No changes.
Oops, something went wrong.

0 comments on commit fbd5ae9

Please sign in to comment.