日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

py2.7+pyqt4开发端口检测工具

發布時間:2023/12/10 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 py2.7+pyqt4开发端口检测工具 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
py2.7+pyqt4開發端口檢測工具

? 使用工具:python2.7,pyqt4,pyinstaller,pywin32

? 先貼代碼

1 import sys 2 from PyQt4 import QtGui,QtCore 3 4 import threading 5 import thread 6 import os 7 import re 8 import urllib 9 import socket 10 import time 11 12 13 global maxNum 14 global cnt 15 global sign 16 17 class Main_QWidget(QtGui.QWidget): 18 def __init__(self): 19 QtGui.QWidget.__init__(self) 20 21 self.ipaddr=QtGui.QLineEdit(self) 22 self.portBegin=QtGui.QLineEdit(self) 23 self.portEnd=QtGui.QLineEdit(self) 24 self.GoButton=QtGui.QPushButton('Go',self) 25 self.out=QtGui.QTextBrowser() 26 27 self.ipinfo=QtGui.QLabel("input the ip : ") 28 self.portinfo1=QtGui.QLabel("input the begin port : ") 29 self.portinfo2=QtGui.QLabel("input the end port : ") 30 self.resinfo=QtGui.QLabel(" the res : ") 31 32 #self.status=QtGui.QTextBrowser() 33 34 grid=QtGui.QGridLayout() 35 36 grid.addWidget(self.ipinfo,0,0,1,3) 37 grid.addWidget(self.ipaddr,1,0,1,3) 38 39 grid.addWidget(self.portinfo1,2,0,1,3) 40 grid.addWidget(self.portBegin,3,0,1,3) 41 42 grid.addWidget(self.portinfo2,4,0,1,3) 43 grid.addWidget(self.portEnd,5,0,1,3) 44 45 grid.addWidget(self.GoButton,6,0,1,3) 46 47 grid.addWidget(self.resinfo,7,0,1,3) 48 grid.addWidget(self.out,8,0,1,3) 49 50 51 #grid.addWidget(self.status,5,1,1,3) 52 53 54 self.resize(300,600) 55 self.setLayout(grid) 56 self.setWindowTitle("find the open port = =") 57 58 self.connect(self.GoButton,QtCore.SIGNAL('clicked()'),gogogo) 59 60 def getIpAddr(self): 61 return self.ipaddr.text() 62 def getPortBegin(self): 63 return self.portBegin.text() 64 def getPortEnd(self): 65 return self.portEnd.text() 66 67 def gogogo1(): 68 print("hello,world\n") 69 print("ip :",main.ipaddr.text()) 70 print("begin: ",main.portBegin.text()) 71 print("end: ",main.portEnd.text()) 72 main.out.append("??") 73 74 def output(temp,interval): 75 main.out.append("open port: "+str(temp)) 76 77 def tryconnect(temp,interval): 78 global cnt 79 global sign 80 s=socket.socket() 81 ttemp=int(temp) 82 t=s.connect_ex((main.ipaddr.text(),ttemp)) 83 if t==0: 84 sign=1 85 #thread.start_new_thread(output,(temp,1)) 86 main.out.append("open port: "+str(ttemp)) 87 print(" find open port: ",ttemp) 88 cnt=cnt-1 89 thread.exit() 90 return True 91 else: 92 cnt=cnt-1 93 thread.exit() 94 return False 95 96 def sleep(temp,interval): 97 time.sleep(1) 98 thread.exit() 99 100 def gogogo(): 101 global cnt 102 global maxNum 103 global sign 104 sign=0; 105 #main.GoButton.setEnabled(0) 106 main.out.append(" finding "+ main.ipaddr.text() + " open port ing...") 107 i=int(main.portBegin.text()); 108 while i<=int(main.portEnd.text()): 109 print("threadnum= ", cnt,"port= ",i) 110 #main.status.append( "cnt= "+str(cnt)+"i= "+str(i) ) 111 if( cnt < maxNum ): 112 thread.start_new_thread(tryconnect,(i,1)) 113 i=i+1 114 cnt=cnt+1 115 #else: 116 # thread.start_new_thread(sleep,(1,1)) 117 # time.sleep(0.1) 118 # print("waiting...") 119 if sign==0: 120 main.out.append(" no open port in range port...") 121 #main.GoButton.setEnabled(1) 122 return True 123 124 125 if __name__=="__main__": 126 global maxNum 127 maxNum=800 128 global cnt 129 cnt=0 130 131 app=QtGui.QApplication(sys.argv) 132 main=Main_QWidget() 133 main.show() 134 sys.exit(app.exec_()) 135 find_open_port

? 先說說遇到的問題,我是python菜鳥,昨天用python3.4寫的,然后各種找,用到啥百度啥,最后終于讓我把程序寫好了,后來打包成exe文件時候遇到問題了,今天上午來卸載了3.4改成了2.7,用pyinstaller打包,成了!

?

? 先寫這么多,到時候補充吧。

posted on 2014-06-19 15:29 symons 閱讀(...) 評論(...) 編輯 收藏

轉載于:https://www.cnblogs.com/symons1992/p/3796714.html

總結

以上是生活随笔為你收集整理的py2.7+pyqt4开发端口检测工具的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。