##// END OF EJS Templates
Work around a bug in setting and getting the mtime in python 2...
Work around a bug in setting and getting the mtime in python 2 See http://bugs.python.org/issue12904. Basically, we can get the mtime in nanosecond precision, but only set it in microsecond precision. This means that the shutil.copy2 will not set the destination's mtime to exactly the same mtime as our source. The end result is that we can *always* end up copying the extension because the source always appears newer. We add a microsecond of fudge time when checking to see if the source is newer than the destination to get around this. This bug is fixed in Python 3.3+, I believe.

File last commit:

r17021:fb8fa759
r20080:52d92404
Show More
handlers.py
59 lines | 1.7 KiB | text/x-python | PythonLexer
MinRK
only use zmq.jsonapi when talking to zmq sockets...
r17021 """Tornado handlers for cluster web service."""
Brian E. Granger
Adding new files.
r10641
MinRK
only use zmq.jsonapi when talking to zmq sockets...
r17021 # Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
Brian E. Granger
Adding new files.
r10641
MinRK
only use zmq.jsonapi when talking to zmq sockets...
r17021 import json
Brian E. Granger
Adding new files.
r10641
from tornado import web
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):
MinRK
only use zmq.jsonapi when talking to zmq sockets...
r17021 self.finish(json.dumps(self.cluster_manager.list_profiles()))
Brian E. Granger
Adding new files.
r10641
class ClusterProfileHandler(IPythonHandler):
@web.authenticated
def get(self, profile):
MinRK
only use zmq.jsonapi when talking to zmq sockets...
r17021 self.finish(json.dumps(self.cluster_manager.profile_info(profile)))
Brian E. Granger
Adding new files.
r10641
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)
MinRK
only use zmq.jsonapi when talking to zmq sockets...
r17021 self.finish(json.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),
]