##// END OF EJS Templates
Splitting handlers into different files....
Splitting handlers into different files. I have also created a top-level utils.py for notebook related stuff

File last commit:

r10642:f9727e68
r10642:f9727e68
Show More
clustersapi.py
57 lines | 1.6 KiB | text/x-python | PythonLexer
"""Tornado handlers for cluster web service.
Authors:
* Brian Granger
"""
#-----------------------------------------------------------------------------
# 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
#-----------------------------------------------------------------------------
from tornado import web
from zmq.utils import jsonapi
from .base import IPythonHandler
#-----------------------------------------------------------------------------
# Cluster handlers
#-----------------------------------------------------------------------------
class MainClusterHandler(IPythonHandler):
@web.authenticated
def get(self):
self.finish(jsonapi.dumps(self.cluster_manager.list_profiles()))
class ClusterProfileHandler(IPythonHandler):
@web.authenticated
def get(self, profile):
self.finish(jsonapi.dumps(self.cluster_manager.profile_info(profile)))
class ClusterActionHandler(IPythonHandler):
@web.authenticated
def post(self, profile, action):
cm = self.cluster_manager
if action == 'start':
n = self.get_argument('n',default=None)
if n is None:
data = cm.start_cluster(profile)
else:
data = cm.start_cluster(profile, int(n))
if action == 'stop':
data = cm.stop_cluster(profile)
self.finish(jsonapi.dumps(data))