# Path: pypot/server/server.py
# class AbstractServer(object):
#     def __init__(self, robot, host, port):
#         self.restful_robot = RESTRobot(robot)
#         self.host, self.port = host, port
# 
#     def run(self):
#         raise NotImplementedError


import json
import socket
import errno
import numpy
import logging
		import socket
from tornado.ioloop import IOLoop
from tornado.web import RequestHandler
from tornado.web import Application
from .server import AbstractServer
	(r'/records/(?P<move_name>[a-zA-Z0-9_]+)/save\.json', SaveMoveHandler),
	(r'/records/(?P<move_name>[a-zA-Z0-9_]+)/play\.json', PlayMoveHandler),
	(r'/records/(?P<move_name>[a-zA-Z0-9_]+)/stop\.json', StopMoveHandler),
	(r'/records/(?P<move_name>[a-zA-Z0-9_]+)/delete\.json', DeleteMoveHandler),

	# Primitives
	(r'/primitives/list\.json', PrimitivesListHandler),
	(r'/primitives/running/list\.json', RunningPrimitivesListHandler),
	(r'/primitives/(?P<primitive_name>[a-zA-Z0-9_]+)/start\.json', StartPrimitiveHandler),
	(r'/primitives/(?P<primitive_name>[a-zA-Z0-9_]+)/stop\.json', StopPrimitiveHandler),
	(r'/primitives/(?P<primitive_name>[a-zA-Z0-9_]+)/pause\.json', PausePrimitiveHandler),
	(r'/primitives/(?P<primitive_name>[a-zA-Z0-9_]+)/resume\.json', ResumePrimitiveHandler),
	(r'/primitives/(?P<primitive_name>[a-zA-Z0-9_]+)/properties/list\.json', PrimitivePropertiesListHandler),
	(r'/primitives/(?P<primitive_name>[a-zA-Z0-9_]+)/properties/(?P<prop>[a-zA-Z0-9_]+)/value\.json',
	 PrimitivePropertyHandler),
	(r'/primitives/(?P<primitive_name>[a-zA-Z0-9_]+)/methods/list\.json', ListPrimitiveMethodsHandler),
	(r'/primitives/(?P<primitive_name>[a-zA-Z0-9_]+)/methods/(?P<method_name>[a-zA-Z0-9_]+)/args\.json',
	 CallPrimitiveMethodHandler),

	# Ik
	(r'/ik/(?P<chain_name>[a-zA-Z0-9_]+)/value\.json', IKValueHandler),
	(r'/ik/(?P<chain_name>[a-zA-Z0-9_]+)/goto\.json', IKGotoHandler),
	(r'/ik/(?P<chain_name>[a-zA-Z0-9_]+)/rpy\.json', IKRPYHandler)
]


class HTTPRobotServer(AbstractServer):
	"""Refer to the REST API for an exhaustive list of the possible routes."""

	def __init__(self, robot, host='0.0.0.0', port='8080', cross_domain_origin='*', **kwargs):

# Path: pypot/server/server.py
# class AbstractServer(object):
#     def __init__(self, robot, host, port):
#         self.restful_robot = RESTRobot(robot)
#         self.host, self.port = host, port
# 
#     def run(self):
#         raise NotImplementedError


# Path: pypot/server/httpserver.py
import json
import socket
import errno
import numpy
import logging
		import socket
from tornado.ioloop import IOLoop
from tornado.web import RequestHandler
from tornado.web import Application
from .server import AbstractServer

	(r'/records/(?P<move_name>[a-zA-Z0-9_]+)/save\.json', SaveMoveHandler),
	(r'/records/(?P<move_name>[a-zA-Z0-9_]+)/play\.json', PlayMoveHandler),
	(r'/records/(?P<move_name>[a-zA-Z0-9_]+)/stop\.json', StopMoveHandler),
	(r'/records/(?P<move_name>[a-zA-Z0-9_]+)/delete\.json', DeleteMoveHandler),

	# Primitives
	(r'/primitives/list\.json', PrimitivesListHandler),
	(r'/primitives/running/list\.json', RunningPrimitivesListHandler),
	(r'/primitives/(?P<primitive_name>[a-zA-Z0-9_]+)/start\.json', StartPrimitiveHandler),
	(r'/primitives/(?P<primitive_name>[a-zA-Z0-9_]+)/stop\.json', StopPrimitiveHandler),
	(r'/primitives/(?P<primitive_name>[a-zA-Z0-9_]+)/pause\.json', PausePrimitiveHandler),
	(r'/primitives/(?P<primitive_name>[a-zA-Z0-9_]+)/resume\.json', ResumePrimitiveHandler),
	(r'/primitives/(?P<primitive_name>[a-zA-Z0-9_]+)/properties/list\.json', PrimitivePropertiesListHandler),
	(r'/primitives/(?P<primitive_name>[a-zA-Z0-9_]+)/properties/(?P<prop>[a-zA-Z0-9_]+)/value\.json',
	 PrimitivePropertyHandler),
	(r'/primitives/(?P<primitive_name>[a-zA-Z0-9_]+)/methods/list\.json', ListPrimitiveMethodsHandler),
	(r'/primitives/(?P<primitive_name>[a-zA-Z0-9_]+)/methods/(?P<method_name>[a-zA-Z0-9_]+)/args\.json',
	 CallPrimitiveMethodHandler),

	# Ik
	(r'/ik/(?P<chain_name>[a-zA-Z0-9_]+)/value\.json', IKValueHandler),
	(r'/ik/(?P<chain_name>[a-zA-Z0-9_]+)/goto\.json', IKGotoHandler),
	(r'/ik/(?P<chain_name>[a-zA-Z0-9_]+)/rpy\.json', IKRPYHandler)
]


class HTTPRobotServer(AbstractServer):
	"""Refer to the REST API for an exhaustive list of the possible routes."""

	def __init__(self, robot, host='0.0.0.0', port='8080', cross_domain_origin='*', **kwargs):

		AbstractServer.__init__(self, robot, host, port)