##// END OF EJS Templates
Define multiline_string type
Define multiline_string type

File last commit:

r11033:fa36e98f
r16910:4d8cb5a9
Show More
handlers.py
72 lines | 2.2 KiB | text/x-python | PythonLexer
Brian E. Granger
Splitting handlers into different files....
r10642 """Tornado handlers for cluster web service.
Brian E. Granger
Adding new files.
r10641
Authors:
* Brian Granger
"""
#-----------------------------------------------------------------------------
Brian E. Granger
Splitting handlers into different files....
r10642 # Copyright (C) 2011 The IPython Development Team
Brian E. Granger
Adding new files.
r10641 #
# 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
Brian E. Granger
Moving web services into a subdir.
r10665 from ...base.handlers import IPythonHandler
Brian E. Granger
Adding new files.
r10641
#-----------------------------------------------------------------------------
# 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':
MinRK
fix default cluster count
r10685 n = self.get_argument('n', default=None)
if not n:
Brian E. Granger
Adding new files.
r10641 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))
Brian E. Granger
More work on the handlers
r10647
#-----------------------------------------------------------------------------
# URL to handler mappings
#-----------------------------------------------------------------------------
_cluster_action_regex = r"(?P<action>start|stop)"
_profile_regex = r"(?P<profile>[^\/]+)" # there is almost no text that is invalid
default_handlers = [
(r"/clusters", MainClusterHandler),
(r"/clusters/%s/%s" % (_profile_regex, _cluster_action_regex), ClusterActionHandler),
(r"/clusters/%s" % _profile_regex, ClusterProfileHandler),
]