wxPythonクライアントログインプロセスの作成

7417 ワード

ログイン関数の初歩的な実装:
def Login(self, event):
    if (self.datacenter._netstat == 0):
        lib.MyDialog(u"    ",u"    ,     ...")
    else:
        lib.udpFindCcu(self.datacenter, self.devdb.getFindCcu())
        if (bool(self.datacenter.ccuArray)):
            self.login_zk_id = self.TextCtrl_login_zkid.GetValue()
            if (self.datacenter.ccuArray.has_key(self.login_zk_id)):
                lib.MyDialog(u"    ",u"               ")
            else:
                lib.MyDialog(u"    ",u"              ")
        else:
            lib.MyDialog(u"    ",u"            ")

ログイン関数の具体的な実装:
    def Login(self, event):
        if self.cpu["Handler"]._login:
            return -1
        self.datacenter = self.cpu["Handler"]
        self.devdb = self.cpu["DB"]

        self.login_zk_id = self.cpu["Button"]["TextCtrl_login_zkid"].GetValue()              #    
        self.login_usr = self.cpu["Button"]["TextCtrl_login_user"].GetValue()                #    
        self.cpu["Handler"]._login_account = str(self.login_usr)
        self.login_pwd = self.cpu["Button"]["TextCtrl_login_pwd"].GetValue()                 #    
        if (self.datacenter._netstat == 0):
            log.info(u"    ,      "+self.login_zk_id)
            lib.udpFindCcu(self.cpu)
            self.login_zk_id = self.cpu["Button"]["TextCtrl_login_zkid"].GetValue()
            if (bool(self.datacenter.ccuArray)):
                if (self.datacenter.ccuArray.has_key(self.login_zk_id)):
                    log.info(u"       ,      ")
                    for key in self.datacenter.ccuArray:
                        if (self.login_zk_id == key):
                            self.tcpClient = lib.TCPClient(self.cpu)
                            try:
                                self.tcpClient.connect(self.datacenter.ccuArray[key], self.datacenter.tcpServerPort)
                            except socket.error, e:
                                log.info(self.datacenter.ccuArray[key])
                                log.info(str(self.datacenter.tcpServerPort))
                                log.error("LoginMethodsRemote() occur error!
Failed to connect to server @ip: "+self.datacenter.ccuArray[key]["ip"]+" | port: "+str(self.datacenter.tcpServerPort)+"
The error is"+str(e)) self.cpu["Button"]["loginBtn"].SetToggle(False) else: self.cpu["tcpClient"] = self.tcpClient self.socket_recv = threading.Thread(target=self.tcpClient.recv, args=()) self.socket_recv.start() self.tcpClient.send(lib.objLogin(self.cpu, self.login_zk_id, self.login_usr, self.login_pwd, 0)) self.tcpClient.loginDataSave(key, self.datacenter.ccuArray[key], self.datacenter.tcpServerPort) break else: lib.MyDialog(u" ",u" , ...") else: lib.udpFindCcu(self.cpu) self.login_zk_id = self.cpu["Button"]["TextCtrl_login_zkid"].GetValue() log.info(u" "+self.login_zk_id) log.info(u" "+str(self.datacenter.ccuArray)) if (bool(self.datacenter.ccuArray)): if (self.datacenter.ccuArray.has_key(self.login_zk_id)): log.info(u" , ") for key in self.datacenter.ccuArray: if (self.login_zk_id == key): self.tcpClient = lib.TCPClient(self.cpu) try: self.tcpClient.connect(self.datacenter.ccuArray[key], self.datacenter.tcpServerPort) except socket.error, e: log.info(self.datacenter.ccuArray[key]) log.info(str(self.datacenter.tcpServerPort)) log.error("LoginMethodsRemote() occur error!
Failed to connect to server @ip: "+str(self.datacenter.ccuArray[key]["ip"])+" | port: "+str(self.datacenter.tcpServerPort)+"
The error is"+str(e)) self.cpu["Button"]["loginBtn"].SetToggle(False) else: self.cpu["tcpClient"] = self.tcpClient self.socket_recv = threading.Thread(target=self.tcpClient.recv, args=()) self.socket_recv.start() self.tcpClient.send(lib.objLogin(self.cpu, self.login_zk_id, self.login_usr, self.login_pwd, 0)) self.tcpClient.loginDataSave(key, self.datacenter.ccuArray[key], self.datacenter.tcpServerPort) break else: log.info(u" , ") self.tcpClient = lib.TCPClient(self.cpu) try: self.tcpClient.connect(self.datacenter.tcpCloudIP, self.datacenter.tcpCloudPort) except socket.error, e: log.error("LoginMethodsRemote() occur error!
Failed to connect to server @ip: "+self.datacenter.tcpCloudIP+" | port: "+self.datacenter.tcpCloudPort+"
The error is"+str(e)) self.cpu["Button"]["loginBtn"].SetToggle(False) else: self.cpu["tcpClient"] = self.tcpClient self.socket_recv = threading.Thread(target=self.tcpClient.recv, args=()) self.socket_recv.start() self.tcpClient.send(lib.objLogin(self.cpu, self.login_zk_id, self.login_usr, self.login_pwd, 0)) self.tcpClient.loginDataSave(self.login_zk_id, self.datacenter.tcpCloudIP, self.datacenter.tcpCloudPort) else: log.info(u" , ") self.tcpClient = lib.TCPClient(self.cpu) try: self.tcpClient.connect(self.datacenter.tcpCloudIP, self.datacenter.tcpCloudPort) except socket.error, e: log.error("LoginMethodsRemote() occur error!
Failed to connect to server @ip: "+self.datacenter.tcpCloudIP+" | port: "+self.datacenter.tcpCloudPort+"
The error is"+str(e)) self.cpu["Button"]["loginBtn"].SetToggle(False) else: self.cpu["tcpClient"] = self.tcpClient self.socket_recv = threading.Thread(target=self.tcpClient.recv, args=()) self.socket_recv.start() self.tcpClient.send(lib.objLogin(self.cpu, self.login_zk_id, self.login_usr, self.login_pwd, 0)) self.tcpClient.loginDataSave(self.login_zk_id, self.datacenter.tcpCloudIP, self.datacenter.tcpCloudPort)