captiv.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:captiv8 作者: wraith-wireless 项目源码 文件源码
def updatesourceinfo(win,iws,c):
    """
     writes current state to info window
     :param win: the info window
     :param iws: the info window output dict should at minimum the keys
            'dev','Driver','Mode','MAC','Manuf','Connected',
     :param c: the current config should be in the form
      config = {'SSID':None, 'dev':None, 'connect':None}
    """
    # set defaults then check the conf dict for a device
    dev = c['dev'] if c['dev'] else '-'*_DEVLEN_
    driver = mode = manuf = '-'*_FIXLEN_
    hwaddr = '-'*_MACLEN_
    conn = '-'
    color = CPS[WHITE]
    if c['dev']:
        try:
            card = pyw.getcard(dev)
            ifinfo = pyw.ifinfo(card)
            driver = ifinfo['driver'][:_FIXLEN_] # trim excess
            hwaddr = ifinfo['hwaddr'].upper()
            manuf = ifinfo['manufacturer'][:_FIXLEN_] # trim excess
            mode = pyw.modeget(card)
            conn = 'Y' if pyw.isconnected(card) else 'N'
            color = CPS[GREEN]
        except pyric.error as _e:
            raise error("ERRNO {0}. {1}".format(_e.errno,_e.strerror))
    win.addstr(iws['dev'][0],iws['dev'][1],dev,color)
    win.addstr(iws['Driver'][0],iws['Driver'][1],driver,color)
    win.addstr(iws['Mode'][0],iws['Mode'][1],mode,color)
    win.addstr(iws['MAC'][0],iws['MAC'][1],hwaddr,color)
    win.addstr(iws['Manuf'][0],iws['Manuf'][1],manuf,color)
    win.addstr(iws['Connected'][0],iws['Connected'][1],conn,color)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号