def run(self): myssl = mySSL("",8001) package=0 while True: #try: #myssl = mySSL("",8001) #package=0 print '(reg)waiting for connection...' self.ClientConn, fromaddr = myssl.SerConn.accept() print '(reg)...connected from:', fromaddr #data=ClientConn.recv(1024) print "Reg package No: %d" % package package+=1 self.fhead = json.loads(self.ClientConn.recv(1024)) print self.fhead self.dbhandler=dbHandler() self.userID=self.dbhandler.isUserValid(self.fhead['username'],self.fhead['password']) if not self.userID: print 'Check your password!' self.ClientConn.close() continue seqType = self.fhead['type'] if seqType == 'up': self.upFile() elif seqType == 'del': self.delFile() self.ClientConn.close()
def run(self): try: print '(down)waiting for connection...' self.ClientConn, fromaddr = self.myssl.SerConn.accept() print '(down)...connected from:', fromaddr package=0 downSEQ().start() while True: #data=ClientConn.recv(1024) print "(",id(self), ")Down package No: %d" % package package+=1 self.fhead = json.loads(self.ClientConn.recv(1024)) self.dbhandler=dbHandler() self.userID=self.dbhandler.isUserValid(self.fhead['username'],self.fhead['password']) if not self.userID: print "(",id(self), ")Check your password!" continue seqType = self.fhead['type'] if seqType == 'list': self.listFile() elif seqType == 'down': self.downFile() except: del downSEQ.SEQS[id(self)]