##// END OF EJS Templates
Merge pull request #2882 from takluyver/utils-cleanup...
Merge pull request #2882 from takluyver/utils-cleanup Utils cleanup. This removes various unused code that was sitting in IPython.utils. I checked that we don't use these functions and modules at present, but we may want to leave some of them for future use or for extension authors. For the first pass, I've been deliberately quite aggressive about removing things.

File last commit:

r5214:d05b9909
r9486:a3c4e796 merge
Show More
iploggerapp.py
103 lines | 3.0 KiB | text/x-python | PythonLexer
MinRK
Refactor newparallel to use Config system...
r3604 #!/usr/bin/env python
# encoding: utf-8
"""
A simple IPython logger application
MinRK
update recently changed modules with Authors in docstring
r4018
Authors:
* MinRK
MinRK
Refactor newparallel to use Config system...
r3604 """
#-----------------------------------------------------------------------------
# Copyright (C) 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.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
import os
import sys
import zmq
MinRK
move ipcluster create|list to `ipython profile create|list`...
r4024 from IPython.core.profiledir import ProfileDir
MinRK
use BaseIPythonApp.load_config, not Application.load_config
r3991 from IPython.utils.traitlets import Bool, Dict, Unicode
MinRK
re-enable log forwarding and iplogger
r3989
MinRK
rename clusterdir to more descriptive baseapp...
r3993 from IPython.parallel.apps.baseapp import (
MinRK
update parallel apps to use ProfileDir
r3992 BaseParallelApplication,
MinRK
Show invalid config message on TraitErrors during initialization...
r5172 base_aliases,
MinRK
catch_config -> catch_config_error
r5214 catch_config_error,
MinRK
Refactor newparallel to use Config system...
r3604 )
MinRK
fix residual import issues with IPython.parallel reorganization
r3688 from IPython.parallel.apps.logwatcher import LogWatcher
MinRK
Refactor newparallel to use Config system...
r3604
#-----------------------------------------------------------------------------
# Module level variables
#-----------------------------------------------------------------------------
#: The default config file name for this application
default_config_file_name = u'iplogger_config.py'
MinRK
parallel docs, tests, default config updated to newconfig
r3990 _description = """Start an IPython logger for parallel computing.
MinRK
Refactor newparallel to use Config system...
r3604
IPython controllers and engines (and your own processes) can broadcast log messages
by registering a `zmq.log.handlers.PUBHandler` with the `logging` module. The
logger can be configured using command line options or using a cluster
directory. Cluster directories contain config, log and security files and are
MinRK
move ipcluster create|list to `ipython profile create|list`...
r4024 usually located in your ipython directory and named as "profile_name".
Brian E. Granger
Finishing up help string work.
r4218 See the `profile` and `profile-dir` options for details.
MinRK
Refactor newparallel to use Config system...
r3604 """
#-----------------------------------------------------------------------------
# Main application
#-----------------------------------------------------------------------------
MinRK
re-enable log forwarding and iplogger
r3989 aliases = {}
aliases.update(base_aliases)
aliases.update(dict(url='LogWatcher.url', topics='LogWatcher.topics'))
MinRK
Refactor newparallel to use Config system...
r3604
MinRK
update parallel apps to use ProfileDir
r3992 class IPLoggerApp(BaseParallelApplication):
MinRK
Refactor newparallel to use Config system...
r3604
MinRK
default config files are automatically generated...
r4025 name = u'iplogger'
MinRK
Refactor newparallel to use Config system...
r3604 description = _description
MinRK
use BaseIPythonApp.load_config, not Application.load_config
r3991 config_file_name = Unicode(default_config_file_name)
MinRK
re-enable log forwarding and iplogger
r3989
MinRK
update parallel apps to use ProfileDir
r3992 classes = [LogWatcher, ProfileDir]
MinRK
re-enable log forwarding and iplogger
r3989 aliases = Dict(aliases)
MinRK
catch_config -> catch_config_error
r5214 @catch_config_error
MinRK
re-enable log forwarding and iplogger
r3989 def initialize(self, argv=None):
super(IPLoggerApp, self).initialize(argv)
self.init_watcher()
def init_watcher(self):
MinRK
Refactor newparallel to use Config system...
r3604 try:
MinRK
reorganize Factory classes to follow relocation of Session object
r4007 self.watcher = LogWatcher(config=self.config, log=self.log)
MinRK
Refactor newparallel to use Config system...
r3604 except:
self.log.error("Couldn't start the LogWatcher", exc_info=True)
self.exit(1)
MinRK
re-enable log forwarding and iplogger
r3989 self.log.info("Listening for log messages on %r"%self.watcher.url)
MinRK
Refactor newparallel to use Config system...
r3604
MinRK
re-enable log forwarding and iplogger
r3989 def start(self):
self.watcher.start()
MinRK
Refactor newparallel to use Config system...
r3604 try:
self.watcher.loop.start()
except KeyboardInterrupt:
self.log.critical("Logging Interrupted, shutting down...\n")
def launch_new_instance():
"""Create and run the IPython LogWatcher"""
MinRK
use App.instance() in launch_new_instance (parallel apps)...
r3999 app = IPLoggerApp.instance()
MinRK
re-enable log forwarding and iplogger
r3989 app.initialize()
MinRK
Refactor newparallel to use Config system...
r3604 app.start()
if __name__ == '__main__':
launch_new_instance()