def run(self): # each new run needs a a new interpreter intrepreter = Interpreter() client, client_addr = self.wait_for_connection() request = self.read_request(client, 1024) bytecode = self._bytecode(request.filename) if bytecode is None: response = u"<html><body><p>404: File not found</p></body></html>" code = 404 else: intrepreter.setup(request) response = intrepreter.run_return(bytecode) code = 200 self.return_response(client, code, response) current_date = str(time.time()) client_addr = '%s:%d' % (client_addr.get_host(), client_addr.get_port()) print "[%s] %s [%d]: %s" % (current_date, client_addr, code, request.filename) self.connection_close(client)
def run(self, code): bc = bytecode('/tmp/example.php', code) intrepreter = Interpreter() return intrepreter.run_return(bc)
def interpret(bc): """ Interpret bytecode and execute it """ intrepreter = Interpreter() intrepreter.run(bc)