def run(self): try: clientSocket = connectionSocket message = clientSocket.recv(512) httpResponse = '' fileContents = '' #parse the http message message = message.strip("\n") print "query = ",message rString = dev_db.evaluateQuery(message,self.clientaddr) #sumanth rString = pickle.dumps(rString) clientSocket.send(rString) except IOError as e: clientSocket.send('File not found to load a table from, server terminating'+time.ctime()) except IncompatibleFileTypeException as e: clientSocket.send(e.value) except RuntimeError as e: clientSocket.send('ERROR 405 : METHOD NOT SUPPORTED ON THIS SERVER ') clientSocket.close() print 'TCP connection to:',clientaddr,'closed', time.ctime()
def run(self): try: exceptionFileHandler = open("exceptionLog.txt","a") connectionLog = open("connectionLog.txt","a") clientSocket = connectionSocket message = clientSocket.recv(512) httpResponse = '' fileContents = '' #parse the http message message = message.strip("\n") print "query = ",message rString = dev_db.evaluateQuery(message,self.clientaddr) rString = pickle.dumps(rString) clientSocket.send(rString) except IOError as e: exceptionFileHandler.write('File not found to load a table from, server terminating'+str(time.ctime())+"\n") clientSocket.send('File not found to load a table from, server terminating'+time.ctime()) except IncompatibleFileTypeException as e: exceptionFileHandler.write(str(e.value)+"\n") clientSocket.send(e.value) clientSocket.close() connectionLog.write('TCP connection to:'+str(self.clientaddr)+'closed'+str(time.ctime())+"\n") print 'TCP connection to:',self.clientaddr,'closed', time.ctime()