##// END OF EJS Templates
parallel docs, tests, default config updated to newconfig
parallel docs, tests, default config updated to newconfig

File last commit:

r3990:080d3c71
r3990:080d3c71
Show More
iploggerapp.py
97 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
"""
#-----------------------------------------------------------------------------
# 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
re-enable log forwarding and iplogger
r3989 from IPython.utils.traitlets import Bool, Dict
MinRK
fix residual import issues with IPython.parallel reorganization
r3688 from IPython.parallel.apps.clusterdir import (
MinRK
ipcluster implemented with new subcommands
r3986 ClusterApplication,
MinRK
re-enable log forwarding and iplogger
r3989 ClusterDir,
base_aliases
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
rebase IPython.parallel after removal of IPython.kernel...
r3672 usually located in your ipython directory and named as "cluster_<profile>".
MinRK
parallel docs, tests, default config updated to newconfig
r3990 See the `profile` and `cluster_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
ipcluster implemented with new subcommands
r3986 class IPLoggerApp(ClusterApplication):
MinRK
Refactor newparallel to use Config system...
r3604
name = u'iploggerz'
description = _description
default_config_file_name = default_config_file_name
MinRK
re-enable log forwarding and iplogger
r3989 auto_create_cluster_dir = Bool(False)
classes = [LogWatcher, ClusterDir]
aliases = Dict(aliases)
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
re-enable log forwarding and iplogger
r3989 self.watcher = LogWatcher(config=self.config, logname=self.log.name)
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"""
app = IPLoggerApp()
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()