Python subprocess 实现ping (三)
来源:互联网 发布:流量统计软件 编辑:程序博客网 时间:2024/06/04 20:05
# -*- coding: GBK -*-
from tkinter import *
import subprocess
def btn_click():
evalue = Ping() #单击按钮调用PING函数
#text.insert(INSERT,evalue.s)
def btn_phct():
phct()
def phct():
ip = ('172.23.128.%d' %(x) for x in range(1,56))
for i in ip:
str_ip = str('ping -n 1 -w 1 %s ' %i)
ret = subprocess.call(str_ip,stdout=subprocess.PIPE,shell=True)
if ret ==0:
text.insert(INSERT,"%s is OK!\n" % i)
text.update()
#print("OK")
elif ret == 1:
text.insert(INSERT,"%s is faild!\n" % i)
def Ping():
v=('172.23.130.%d' % (x) for x in range(1,11))
for it in v:
loop = str('ping -n 1 -w 1 %s' % it)
ret = subprocess.call(loop,stdout=subprocess.PIPE,shell=True)
if ret ==0:
text.insert(INSERT,("%s is OK!\n" % it))
text.update()
#print("OK")
elif ret == 1:
text.insert(INSERT,("%s is faild!\n" % it))
#print("faild")
'''
if ret:
s = str('ping %s fail \n' % it )
text.insert(INSERT,s)
else:
s=str('ping %s OK \n' % it )
text.insert(INSERT,s)'''
root = Tk()
root.title('Ping')
main_frame = Frame(root)
text_frame=Frame(main_frame)
botton_frame=Frame(main_frame)
l1 = Label(main_frame,text='机台连线')
l1.pack(side='top')
b = Button(botton_frame,text='SORTER',command=btn_click)
b1 = Button(botton_frame,text='HCT',command=btn_phct)
b['width']=10
b['height']=2
b1['width']=10
b1['height']=2
b.pack(side = TOP)
b1.pack(side = TOP)
text = Text(text_frame,width = 30, height= 25)
text.pack(side=TOP)
main_frame.pack()
botton_frame.pack(side='right')
text_frame.pack(side='left')
root.mainloop()
- Python subprocess 实现ping (三)
- python利用subprocess实现多进程
- python subprocess
- python subprocess
- PYTHON SUBPROCESS
- Python --- subprocess
- python subprocess
- python subprocess
- python -- subprocess
- python subprocess
- Python-subprocess
- python----subprocess
- python实现ping源代码
- 使用python subprocess模块实现调用shell执行命令
- python实现增强版ping
- python实现ping的源代码
- Python实现ping指定IP
- Python ping 实现(一)
- 与第三方ERP系统同步数据总结
- Nginx安装-Tengine(阿里baba的)
- linux安装配置redis
- ef 仓储模式 Redis
- iOS集成linphone
- Python subprocess 实现ping (三)
- Easyui框架 validatebox 与 textbox 的区别
- const 和 readonly 的区别
- 基础最短路三 POJ 1797
- MyEclipse10安装Svn插件的几种方法
- 【备忘】SoapUI测试REST风格接口时的groovy script写法
- c:forEach varStatus属性
- SSH免密码互相登陆-搭建hadoop集群
- 获取数字签名