예제 #1
0
    def getNodeHandlers(self):

        try:
            files_folders = os.listdir(self.log_folder)
        except KeyError:
            raise Exception(
                "Must specify a valid directory where the logs are")

        nodes_handlers = []

        if self.simulate:
            date = [
                datetime.strptime(folder.replace('_', ' '), "%d%m%y %H%M")
                for folder in folders
            ]
            newest = files_folders[date.index(min(date))]
            copy_tree(self.log_folder, '../res/logs_sim')
            self.log_folder = '../res/logs_sim'

            try:
                boards = os.listdir(os.path.join(self.log_folder, newest))
            except KeyError:
                raise Exception(
                    "Must specify a valid directory where the logs are")

            for board in boards:
                node_reader = NodeReader(self.log_folder, board, self.simulate)
                node_formatter = NodeFormatter(node_reader)
                signal_set = '7sols_' + board
                fivis_requester = self._getFivisRequester(
                    signal_set, node_formatter.getSchema())
                nodes_handlers.append(
                    RequestHandler(node_formatter, fivis_requester))
        else:

            logs = files_folders

            for log in logs:
                board = log.replace('.log', '').split('_')[1]
                node_reader = NodeReader(self.log_folder + log, board,
                                         self.simulate)
                node_formatter = NodeFormatter(node_reader)
                signal_set = '7sols_' + board
                fivis_requester = self._getFivisRequester(
                    signal_set, node_formatter.getSchema())
                nodes_handlers.append(
                    RequestHandler(node_formatter, fivis_requester))

        return nodes_handlers
예제 #2
0
 def process_request(self, request):
     code = 200
     try:
         result = RequestHandler.handle(request)
         return HttpResponse(result.serialize(result.encode(request)),
                             content_type=result.content_type,
                             status=code)
     except Exception as e:
         result, content_type = OWSExceptionHandler.handle(e)
         code = 400
         return HttpResponse(result, content_type=content_type, status=code)
예제 #3
0
 def listen(self):
     print "TCPServer is listening at %s:%d!" % (self.host, self.port)
     hf = HandlerFactory(self.commands)
     while True:
         logging.debug("TCPServer accepting requests.")
         client_sock, client_addr = self.socket.accept()
         client_host, client_port = client_addr
         logging.debug("TCPServer handling request from %s:%s." %
                       (client_host, client_port))
         handler = RequestHandler(hf, client_host, client_port, client_sock)
         self.request_queue.apply(handler.handle, ())
     self.socket.close()
예제 #4
0
	def __init__(self,*args, **kwargs):
		RequestHandler.__init__(self, *args, **kwargs);
예제 #5
0
 def setUp(self):
     self._handler = RequestHandler()
예제 #6
0
 def addHandler(self, handler: RequestHandler):
     self.handlers[handler.getId()] = handler