本文整理汇总了Python中wifi.Cell.where方法的典型用法代码示例。如果您正苦于以下问题:Python Cell.where方法的具体用法?Python Cell.where怎么用?Python Cell.where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wifi.Cell
的用法示例。
在下文中一共展示了Cell.where方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_cell
# 需要导入模块: from wifi import Cell [as 别名]
# 或者: from wifi.Cell import where [as 别名]
def find_cell(interface, query):
cell = Cell.where(interface, lambda cell: cell.ssid.lower() == query.lower())
try:
cell = cell[0]
except IndexError:
cell = fuzzy_find_cell(interface, query)
return cell
示例2: fuzzy_find_cell
# 需要导入模块: from wifi import Cell [as 别名]
# 或者: from wifi.Cell import where [as 别名]
def fuzzy_find_cell(interface, query):
match_partial = lambda cell: fuzzy_match(query, cell.ssid)
matches = Cell.where(interface, match_partial)
num_unique_matches = len(set(cell.ssid for cell in matches))
assert num_unique_matches > 0, "Couldn't find a network that matches '{}'".format(query)
assert num_unique_matches < 2, "Found more than one network that matches '{}'".format(query)
# Several cells of the same SSID
if len(matches) > 1:
matches.sort(key=lambda cell: cell.signal)
return matches[0]
示例3: run_scan
# 需要导入模块: from wifi import Cell [as 别名]
# 或者: from wifi.Cell import where [as 别名]
def run_scan(self):
scan = Cell.where(interface, filter)
if(len(scan) > 0):
network = scan[0]
if(network.encrypted):
if(network.encryption_type is 'wep'):
return (10, "WEP Network Detected - Passwords can easily be hacked.")
if(network.encryption_type is 'wpa'):
return (20, "WPA Network Detected - Passwords may be vulnerable.")
if(network.encryption_type is 'wpa2'):
return (100, "Network encryption appears secure")
else:
return (100, "Network encryption apperas secure")
else:
return (0, "No network encryption")
示例4: connect
# 需要导入模块: from wifi import Cell [as 别名]
# 或者: from wifi.Cell import where [as 别名]
def connect(esid, passkey=None, intf='wlan0'):
cells = Cell.where(intf, lambda c: c.ssid == esid);
if len(cells) == 0:
raise LookupError('Network was not found');
if len(cells) > 1:
raise LookupError('Sorry, network SSID is ambiguous');
scheme = Scheme.for_cell(intf, STORED_SCHEME_NAME, cells[0], passkey);
old = Scheme.find(intf, STORED_SCHEME_NAME);
if old is not None:
old.delete();
scheme.save();
scheme.activate();
示例5: connect
# 需要导入模块: from wifi import Cell [as 别名]
# 或者: from wifi.Cell import where [as 别名]
def connect(adapter, ssid, psk=None, quiet=False):
if not quiet:
print "***setting up wireless adapter***"
signal = []
# get a list of all the available SSIDs that match the arg ssid
cells = Cell.where(adapter, lambda x: x.ssid == ssid)
print cells
if len(cells) == 0:
if not quiet:
print "Cannot find SSID:", ssid
return False
# find the SSID with the best signal strength and select it as the cell to connect to
for c in cells:
signal.append(c.signal)
max_signal = max(signal)
max_index = signal.index(max_signal)
cell = cells[max_index]
scheme = Scheme.for_cell(adapter, ssid, cell, passkey=psk)
# overwrite the scheme if already in '/etc/network/interfaces'
# save it to '/etc/network/interfaces' if not
if Scheme.find(adapter, ssid):
scheme.delete()
scheme.save()
else:
scheme.save()
# attempt to connect to ssid
try:
if not quiet:
print 'connecting to SSID:', cell.ssid
scheme.activate()
if not quiet:
print 'connection successful'
return True
except:
if not quiet:
print('connection failed')
return False
示例6: log
# 需要导入模块: from wifi import Cell [as 别名]
# 或者: from wifi.Cell import where [as 别名]
estado = 1
log(1, "Reset ifconfig y dhclient")
log(0, "configuracion leida.")
except:
# error.
log(5, "Imposible leer la configuracion" )
wifi = 0
conectado=0
internet=0
estado = 0
wait= 10
elif estado ==1:
# buscamos el ssid:
try:
cell = Cell.where("wlan0", lambda cell: cell.ssid.lower() == wifissid.lower())
if ( cell ==[]):
# error.
log(3, "Imposible Encontrar la wifissid %s " %wifissid )
wifi = 1
estado = 1
wait = 10
else:
log(0, "red -%s- encontrada."%wifissid)
wifi = 1
wait = 0.1
estado = 2
except:
log(5, "Imposible leer redes wifi error de wlan0" )
wifi = 0
conectado=0