WxPython client Sign-in process development

Source: Internet
Author: User

Initial implementation of the login function:

def Login (self, event):    if (Self.datacenter._netstat = = 0):        lib. Mydialog (U "Network Status", "U" NET exception, please check networks ... ")    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 "login Mode", u "has been searched for corresponding host to start local login")            else:                lib. Mydialog (U "login Mode", u "no search to corresponding host to start remote login")        else:            lib. Mydialog (U "login Mode", u "no search to host direct telnet")


The specific implementation of the login function:

    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 = SE lf.cpu["button" ["Textctrl_login_pwd"]. GetValue () #用户密码 if (Self.datacenter._netstat = = 0): Log.info (U "network exception, starting local discovery" +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 "search to corresponding host, start local login") 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!\nfailed to connect to server @ip:" +self.datac enter.ccuarray[key]["IP"]+ "| Port: "+str (Self.datacenter.tcpServerPort) +" \nthe error is "+STR (e)) self.cpu[" button "[" Log Inbtn "].                                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.tcpServerPor T) break else:lib. Mydialog (U "Network Status", "U" NET exception, please check networks ... ") ELSE:LIB.UDPFINDCCU (self.cpu) self.login_zk_id = self.cpu ["Button"] ["Textctrl_login_zkid"].            GetValue () log.info (u "Login's central control number" +self.login_zk_id) log.info (U "Search in control List" +str (Self.datacenter.ccuArray))                    if (bool (Self.datacenter.ccuArray)): if (Self.datacenter.ccuArray.has_key (self.login_zk_id)):                        Log.info (U "search to corresponding host, start local login") 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]) lo G.info (str (self.datacenter.tcpServerPort)) Log.error ("Loginmethodsremote () occur ERROR!\NFA iled to connect to server @ip: "+str (self.datacenter.ccuarray[key][" IP "]) +" | Port: "+str (Self.datacenter.tcpServerPort) +" \nthe error is "+STR (e)) self.cpu[" button "[" Log Inbtn "].                                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 "did not search to the corresponding host, start remote login") SELF.TCPCL Ient = lib. TCPClient (SELF.CPU) try:self.tcpClient.connect (Self.datacenter.tcpCloudIP, self . datacenter.tcpcloudport) except Socket.error, E:log.error ("Loginmethodsremote ( occur error!\nfailed to connect to server @ip: "+self.datacenter.tcpcloudip+" | Port: "+self.datacenter.tcpcloudport+" \nthe 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.tc Pclient.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 "not found to host, direct telnet") Self.tcpclient = lib. TCPClient (SELF.CPU) try:self.tcpClient.connect (Self.datacenter.tcpCloudIP, Self.datacen Ter.tcpcloudport) except Socket.error, E:log.error ("Loginmethodsremote () occur error!\n Failed to connect to server @ip: "+self.datacenter.tcpcloudip+" | Port: "+self.datacenter.tcpcloudport+" \nthe error is "+STR (e)) self.cpu[" button "[" Loginbtn "]. Settoggle (False) else:self.cpu["tcpClient"] = self.tcpclient self.so CKET_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)

WxPython client Sign-in process development

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.