1 ImportAppuifw as UI2 ImportHttplib3 fromOsImportAbort4Uia=Ui.app5uin=Ui.note6uiq=Ui.query7E32=ui.e328socket=Httplib.socket9 defCN (x):returnX.decode ('UTF8')Tenuia.body=txt=UI. Text () One GlobalDiC Adic={'P':"'} -Run=1 - the defOU (url,ret=1): - #socket.access_point (dic[' P ']). Start () -Con=httplib. Httpconnection ('10.0.0.172', 80) -Con.putrequest ('GET', URL) +Con.putheader ('Accept','*/*') - con.endheaders () + ifret: AR=Con.getresponse () atData=cn (R.read ()) - con.close () - returnData - Else: - con.close () - return in - defquit (): to ifUIQ (CN ("do you want to exit the program? "),"Query"): + ifLock: - lock.signal () the Else: * abort () $Name=uia.full_name (). Split ('\\') [ -1][:-4].lower ()Panax Notoginseng ifNameinch['PED','AppMgr']: -lock=E32. Ao_lock () the Else: +lock=None A defStop (): the GlobalRun +run=0 -UIA.TITLE=CN ('has stopped!') $ $ - defstart (): -Run=1 the GlobalRun -a1=0Wuyi whileRun: theA1+=1 - WuUIA.TITLE=CN ('%s Times'%A1) - Try: AboutDa=ou ('http://3g.qq.cn') $Txt.set (da[200:400]) -UIA.TITLE=CN ('%s Times'%A1) -Da=ou ('http://wap.ucweb.com') -Txt.set (da[200:400]) A except:Pass +E32.ao_sleep (2) the - $Uia.exit_key_handler=quit the defMain (): theUia.menu=[(CN ('Start'), start), (CN ('Stop'), stop), (CN ('Exit'), quit)] the the ifLock: - lock.wait () in if1: theUIn (CN ("Please select Cmwap access point")) thedic['P']=Socket.select_access_point () AboutTxt.set (CN ('\ t network test ...%s'%str (dic['P']). Encode ('Hex'))) the Try: theOu'http://3gsoft.5wap.net') theUIn (CN ('Network Test Success')) + except: -UIn (CN ('Network test Failed')) theTxt.set ("')BayiMain ()
Python Network connection