贫僧是来化妞的 2020-10-18 20:33
浏览 62

ping Scan() missing 1 required positional argument问题

新手小白
我在写期末作业的时候遇到了这个问题
图片说明
下面是代码

import wx
import sys
import ping
import socket
from time import gmtime,strftime
def pingScan(event,results):
if hostEnd.GetValue()<hostStart.GetValue():
dlg=wx.MessageDialog(mainWin,"Invalid Local Host Selection",wx.OK|wx.ICON_EXCLAMATION)
results=dlg.ShowModal()
dlg.Destroy()
return
mainWin.StatusBar.SetStatusText('Excuting Ping Sweep....Please Wait')
utcStarrt=gmtime()
utc=strftime("%a,%d %b %Y %X +0000",utcStarrt)
results.AppendText("\n\nPing Sweep Started:"+utc+"\n\n")
baseIP=str(ipaRange.GetValue())+'.'+str(ipRange.GetValue())+'.'+str(ipcRange.GetValue())+'.'
ipRange=[]
for i in range(hostStart.GetValue(),(hostEnd.GetValue()+1)):
ipRange.append(baseIP=str(i))
for ipAddress in ipRange:
try:
mainWin.StatusBar.SetStatusText('Pinging IP:+ipAddress')
delay=ping.do_one(ipAddress,timeout=2)
results.AppendText(ipAddress+'\t')
if delay!=None:
results.AppendText('Response Success')
results.AppendText('Response Time:'+str(delay)+'Seconds')
results.AppendText("\n")
else:
results.AppendText('Response Timeout')
results.AppendText("\n")
except(socket.error,e):
results.AppendText(ipAddress)
results.AppendText('Response Failed:')
results.AppendText(e.message)
results.AppendText("\n")
utcEnd=gmtime()
utc=strftime("%a,%d %b %Y %X +0000",utcEnd)
esults.AppendText("\nPing Sweep Ended:"+utc+"\n\n")
return
def programExit(event):
sys.exit()
app=wx.App()
mainWin=wx.Frame(None,title="Simple Ping(ICMP)Sweep 1.0",size=(1200,1200))
panelAction=wx.Panel(mainWin)
scanButton=wx.Button(panelAction,label='Exit')
scanButton.Bind(wx.EVT_BUTTON,pingScan)
exitButton=wx.Button(panelAction,label='Scan')
exitButton.Bind(wx.EVT_BUTTON,pingScan)
Results=wx.TextCtrl(panelAction,style=wx.TE_MULTILINE|wx.HSCROLL)
ipaRange=wx.SpinCtrl(panelAction,-1,'')
ipaRange.SetRange(0,255)
ipaRange.SetValue(127)
ipbRange=wx.SpinCtrl(panelAction,-1,'')
ipbRange.SetRange(0,255)
ipbRange.SetValue
ipcRange=wx.SpinCtrl(panelAction, -1,'')
ipcRange.SetRange(0,255)
ipcRange.SetValue(0)
ipLabel=wx.StaticText(panelAction, label="IP Base: ")

hostStart=wx.SpinCtrl(panelAction,-1,'')
hostStart.SetRange(0,255)
hostStart.SetValue(1)

hostEnd=wx.SpinCtrl(panelAction,-1,'')
hostEnd.SetRange(0,255)
hostEnd.SetValue(10)

HostStartLabel=wx.StaticText(panelAction, label="Host Start: ")
HostEndLabel =wx.StaticText(panelAction, label="Host End: ")

actionBox=wx.BoxSizer()
actionBox.Add(scanButton,proportion=1,flag=wx.LEFT,border=5)
actionBox.Add(exitButton,proportion=0,flag=wx.LEFT,border=5)

actionBox.Add(ipLabel,proportion=0,flag=wx.LEFT,border=5)

actionBox.Add(ipaRange,proportion=0,flag=wx.LEFT,border=5)
actionBox.Add(ipbRange,proportion=0,flag=wx.LEFT,border=5)
actionBox.Add(ipcRange,proportion=0,flag=wx.LEFT,border=5)

actionBox.Add(HostStartLabel,proportion=0,flag=wx.LEFT|wx.CENTER,border=5)

actionBox.Add(hostStart,proportion=0,flag=wx.LEFT,border=5)

actionBox.Add(HostEndLabel,proportion=0,flag=wx.LEFT|wx.CENTER,border=5)
actionBox.Add(hostEnd,proportion=0,flag=wx.LEFT,border=5)

vertBox=wx.BoxSizer(wx.VERTICAL)
vertBox.Add(actionBox,proportion=0,flag=wx.EXPAND|wx.ALL,border=5)
vertBox.Add(Results,proportion=1,flag=wx.EXPAND| wx.LEFT| wx.BOTTOM | wx.RIGHT, border=5)

mainWin.CreateStatusBar()

panelAction.SetSizer(vertBox)

mainWin.Show()

app.MainLoop()


  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?