当前位置: 首页>>代码示例>>Python>>正文


Python Cell.where方法代码示例

本文整理汇总了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
开发者ID:Evanito,项目名称:wifi,代码行数:10,代码来源:cli.py

示例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]
开发者ID:Evanito,项目名称:wifi,代码行数:16,代码来源:cli.py

示例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")
开发者ID:Angel-2,项目名称:BITCAMP-2k16,代码行数:17,代码来源:wifi_type.py

示例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();
开发者ID:anly2,项目名称:raspberry-spi,代码行数:19,代码来源:wifi_helper.py

示例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
开发者ID:avninja,项目名称:laundryMonitor,代码行数:44,代码来源:pifi.py

示例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
开发者ID:martinalberto,项目名称:albert-ideas,代码行数:33,代码来源:connect_wifi.py


注:本文中的wifi.Cell.where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。