本文整理汇总了Python中wifi.Cell类的典型用法代码示例。如果您正苦于以下问题:Python Cell类的具体用法?Python Cell怎么用?Python Cell使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Cell类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: ScanWIFI
def ScanWIFI(card):
try:
wifiCell = Cell.all(card)
except:
wifiCell = Cell.all('wlan0')
SendData("Something went wrong... using wlan0")
for i in range(0,len(wifiCell)):
SendData(str(wifiCell[i]) + " is encrypted: "+ str(wifiCell[i].encrypted) + "= " + str(wifiCell[i].encryption_type) + " | address: " +str(wifiCell[i].address))
SendData("ScanWIFI-finished")
开发者ID:pielco11,项目名称:T2B-framework,代码行数:9,代码来源:Mac-client.py
示例2: test_unencrypted
def test_unencrypted(self):
cell = Cell()
cell.ssid = 'SSID'
cell.encrypted = False
scheme = Scheme.for_cell('wlan0', 'test', cell)
self.assertEqual(scheme.options, {
'wireless-essid': 'SSID',
'wireless-channel': 'auto',
})
开发者ID:Evanito,项目名称:wifi,代码行数:11,代码来源:test_schemes.py
示例3: __call__
def __call__(self, iface):
if not isinstance(iface, Iface):
raise ValueError(
'must be of type: net_conf.providers.Iface'
)
if not iface.is_wireless():
raise TypeError(
'must be of type: wireless'
)
cell = Cell([])
cell.essid = self.essid
cell(iface)
开发者ID:baccenfutter,项目名称:netconf,代码行数:12,代码来源:providers.py
示例4: wifi_scan
def wifi_scan():
global connected
reconnected = 0
while 1:
print "Reconnected %d" %reconnected
#Connected, check if still in range
if connected != "":
aps = Cell.all(interface)
inrange = 0
for ap in range(0, len(aps)):
if aps[ap].ssid == connected and aps[ap].signal <= -50:
inrange = 1
if inrange != 1:
connected = ""
else:
time.sleep(20)
#Not connected
else:
aps = Cell.all(interface)
for ap in range(0, len(aps)):
if aps[ap].ssid in known_ssids:
passwd = known_ssids_pass[known_ssids.index(aps[ap].ssid)]
scheme = Scheme.for_cell(interface, "target", aps[ap], passwd)
scheme.delete()
scheme.save()
try:
scheme.activate()
connected = aps[ap].ssid
reconnected += 1
break
except:
print "Could not connect"
continue
#connect to the AP and stop scanning (return connected = ssid?)
else:
for ap in range(0, len(aps)):
if aps[ap].encrypted == False and connected == "":
scheme = Scheme.for_cell(interface, "target", aps[ap])
scheme.delete()
scheme.save()
try:
scheme.activate()
connected = aps[ap].ssid
reconnected += 1
break
except:
print "could not connect"
continue
else:
time.sleep(10)
开发者ID:Apatride,项目名称:algo,代码行数:53,代码来源:net_scan.py
示例5: test_wpa
def test_wpa(self):
cell = Cell()
cell.ssid = 'SSID'
cell.encrypted = True
cell.encryption_type = 'wpa'
scheme = Scheme.for_cell('wlan0', 'test', cell, 'passkey')
self.assertEqual(scheme.options, {
'wpa-ssid': 'SSID',
'wpa-psk': 'ea1548d4e8850c8d94c5ef9ed6fe483981b64c1436952cb1bf80c08a68cdc763',
'wireless-channel': 'auto',
})
开发者ID:Evanito,项目名称:wifi,代码行数:13,代码来源:test_schemes.py
示例6: test_wep_hex
def test_wep_hex(self):
cell = Cell()
cell.ssid = 'SSID'
cell.encrypted = True
cell.encryption_type = 'wep'
# hex key lengths: 10, 26, 32, 58
hex_keys = ("01234567ab", "0123456789abc" * 2, "0123456789abcdef" * 2, "0123456789abc" * 2 + "0123456789abcdef" * 2)
for key in hex_keys:
scheme = Scheme.for_cell('wlan0', 'test', cell, key)
self.assertEqual(scheme.options, {
'wireless-essid': 'SSID',
'wireless-key': key
})
开发者ID:Evanito,项目名称:wifi,代码行数:15,代码来源:test_schemes.py
示例7: test_wep_ascii
def test_wep_ascii(self):
cell = Cell()
cell.ssid = 'SSID'
cell.encrypted = True
cell.encryption_type = 'wep'
# ascii key lengths: 5, 13, 16, 29
ascii_keys = ('a' * 5, 'a' * 13, 'a' * 16, 'a' * 29)
for key in ascii_keys:
scheme = Scheme.for_cell('wlan0', 'test', cell, key)
self.assertEqual(scheme.options, {
'wireless-essid': 'SSID',
'wireless-key': 's:' + key
})
开发者ID:Evanito,项目名称:wifi,代码行数:15,代码来源:test_schemes.py
示例8: sample_interface_neighbourhood
def sample_interface_neighbourhood(network_interface, networks = None, network_states = None):
"""sample interface neighbourhood"""
networks = networks if networks else {}
network_states = network_states if network_states else {}
timestamp = str(datetime.datetime.now())
cells = Cell.all(network_interface)
for cell in cells:
network_key = render_network_key(cell.ssid, cell.address)
if network_key not in networks.keys():
network = new_network(
cell.address, cell.ssid, cell.frequency,
cell.encryption_type if cell.encrypted else None, cell.encrypted, cell.mode,
cell.bitrates, cell.channel)
networks[network_key] = network
network_states[network_key] = new_network_state()
network_state = network_states[network_key]
network_state['time'].append(time)
network_state['signal'].append(cell.signal)
network_state['quality'].append(cell.quality)
return networks, network_states
开发者ID:davidbarkhuizen,项目名称:pyfi,代码行数:30,代码来源:wifitools.py
示例9: get
def get(self):
cells = Cell.all('wlan0')
items = []
for cell in cells:
items.append(cell.__dict__)
self.write(json.dumps(items))
开发者ID:matgallacher,项目名称:Mopidy-Material-Webclient,代码行数:7,代码来源:__init__.py
示例10: handler
def handler(self):
if receive == 'scan':
print 'Connection from {}'.format(str(self.addr))
print 'Status: {}'.format(receive)
file = open('/etc/wpa_supplicant/wpa_supplicant.conf', 'r')
currentWifi = file.readlines()
dataSplit = currentWifi[4].split('ssid="')[1]
currentSSID = dataSplit.split('"')[0]
file.close()
data = Cell.all('wlan0')
self.clientsocket.send(str(len(data)) + '\r\n')
self.clientsocket.send(currentSSID + '\r\n')
for i in range(len(data)):
splitSSid = str(data[i]).split('=')[1]
self.clientsocket.send(str(splitSSid.split(')')[0]) + '\r\n')
print 'Exit ScanWifi'
if 'modify' in receive:
print 'Status: {}'.format(receive)
ssid = receive.split(':')[1]
password = receive.split(':')[2]
editFile = open('/etc/wpa_supplicant/wpa_supplicant.conf','w')
editFile.write('ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev\n')
editFile.write('update_config=1\n')
editFile.write('\nnetwork={\n ssid="')
editFile.write(ssid)
editFile.write('"\n psk="')
editFile.write(password)
editFile.write('"\n}')
editFile.close()
print 'Exit Modify Wifi'
os.system("sudo reboot")
开发者ID:Tsunakung,项目名称:Doorbell-Intelligent-System,代码行数:32,代码来源:SocketServer.py
示例11: scan
def scan(self, event=None):
LOG.info("Scanning wifi connections...")
networks = {}
status = self.get_status()
for cell in Cell.all(self.iface):
if "x00" in cell.ssid:
continue # ignore hidden networks
update = True
ssid = cell.ssid
quality = self.get_quality(cell.quality)
# If there are duplicate network IDs (e.g. repeaters) only
# report the strongest signal
if networks.__contains__(ssid):
update = networks.get(ssid).get("quality") < quality
if update and ssid:
networks[ssid] = {
'quality': quality,
'encrypted': cell.encrypted,
'connected': self.is_connected(ssid, status)
}
self.ws.emit(Message("mycroft.wifi.scanned",
{'networks': networks}))
LOG.info("Wifi connections scanned!\n%s" % networks)
开发者ID:Holly-Buteau,项目名称:mycroft-core,代码行数:25,代码来源:main.py
示例12: testWifi
def testWifi(GPIO,pinDict,x2,mbRetries,wifiNetwork,wifiRetries):
powerOn(GPIO,pinDict,"IO1")
print ("=====================")
print (datetime.datetime.now().strftime("%Y.%m.%d_%H.%M.%S"))
print ("=====================")
#NEED TO TURN ON WIFI SWITCH
searchString=wifiNetwork
retries=wifiRetries
sleepSec = 2
for i in range(0,retries):
ssids=[cell.ssid for cell in Cell.all('wlan0')]
print("List of all networks found:",ssids)
for ssid in ssids:
if (searchString in ssid):
done=True
print("Attempt", i+1, "of", retries, "was successful")
print("Found network:",ssid)
break
else:
done=False
if(done):
return ["Pass"]
else:
print("Failed to find a network with", searchString, "in it on attempt", i+1, "of", retries)
if(i+1<retries):
print("Waiting", sleepSec, "seconds and retrying...")
time.sleep(sleepSec)
else:
print("Failed to find X2 network")
return ["Fail-Network not found"]
开发者ID:kstevens159,项目名称:X2Tester,代码行数:33,代码来源:Fullx2Diag.py
示例13: scan
def scan(iface):
exp_backoff=1
for _ in range(5):
results = []
for cell in Cell.all(iface):
c = {
'ssid': cell.ssid,
'frequency': cell.frequency,
'bitrates': cell.bitrates,
'encrypted': cell.encrypted,
'channel': cell.channel,
'address': cell.address,
'mode': cell.mode,
'quality': cell.quality,
'signal': cell.signal
}
if cell.encrypted:
c['encryption_type'] = cell.encryption_type
results.append(c)
results.sort(key=lambda x: x['signal'], reverse=True)
if (len(results) > 0):
break
sleep(exp_backoff)
exp_backoff *= 2
#retry
return jsonify(results=results)
开发者ID:spektom,项目名称:jutsu,代码行数:27,代码来源:plugin.py
示例14: network_wlan
def network_wlan():
ALL_IP = ip_addresses()
url = request.url_root
url = url[7:-1]
dicts = {
'ALL_IP': ALL_IP,
'IP': ALL_IP['IP'],
'using_desktop': using_desktop(),
'url': url,
}
form=ConnectWifi(request.form)
#dsadsa
cell = Cell.all('wlan0')
ssid=[]
for c in cell:
ssid.append(c.ssid)
if request.method == 'POST':
wifi_name = form.ssid.data
password = form.password.data
cmd = 'nmcli dev wifi connect ' + wifi_name + ' password ' + password
system(cmd)
return cmd
return render_template('network/network_wlan.html',
wlan=ssid, form=form, dicts=dicts)
开发者ID:merlinsbeard,项目名称:blox-user-homepage,代码行数:28,代码来源:blox.py
示例15: scan
def scan(self):
print "Scan Start"
while True:
cell = Cell.all(interface)
print "Rescanning"
timer = 0
while timer < 100:
timer +=1
S = []
count = 0
for c in cell:
count += 1
#print ":"+ str(count), " ssid:", c.ssid
#create dictionary with informnation on the accesss point
SSIDS = {"no" : count ,"ssid": c.ssid, "channel":c.channel,"encrypted":c.encrypted, \
"frequency":c.frequency,"address":c.address, "signal":c.signal, "mode":c.mode}
#if not db.search((where('ssid') == ap["ssid"])) == []:
# res = db.search(where('ssid') == c.ssid)
#print db.search(where('ssid') == c.ssid)
print "=----------------------------------"
# print c.address
print "---------------------------------------"
if db.contains(where('ssid') == c.ssid):
print (db.contains((where('ssid') == c.ssid) & (where('address') == str(c.address))))
开发者ID:baggybin,项目名称:RogueDetection,代码行数:26,代码来源:wifii_scanner.py
示例16: new_wifi_connection
def new_wifi_connection(self):
ssids = [cell.ssid for cell in Cell.all('wlan0')]
if len(ssids) > 0:
ssid = ssids[self.ui.select_from_list(ssids,display_message="Select SSID",controls=False)]
pwd = self.ui.enter_text("Enter SSID pwd",Menu.space+Menu.letters+Menu.numbers+Menu.symbols)
self.core.setup_wifi_connection(ssid,pwd)
return self.edit_wifi_menu
开发者ID:opieters,项目名称:wcamera,代码行数:7,代码来源:menu.py
示例17: locate
def locate():
aps = {}
try:
from wifi import Cell
except:
pass
else:
interfaces = netifaces.interfaces()
for interface in interfaces:
try:
cells = Cell.all(interface)
except:
pass
else:
for ap in cells:
strength = [int(i) for i in ap.quality.split('/')]
aps[ap.address] = 0-int(strength[0]/strength[1]*100)
try:
import NetworkManager
manager = NetworkManager.NetworkManager
except:
pass
else:
for dev in manager.GetDevices():
sdev = dev.SpecificDevice()
if sdev.__class__.__name__ == 'Wireless':
for ap in sdev.GetAccessPoints():
aps[ap.HwAddress] = 0-ord(ap.Strength)
data = urllib.parse.urlencode([('wifi', 'mac:%s|ss:%d' % (mac, strength)) for mac, strength in aps.items()])
f = urllib.request.urlopen('https://maps.googleapis.com/maps/api/browserlocation/json?browser=python&sensor=true&%s' % data)
response = json.loads(f.read().decode('utf-8'))
return response['location']['lat'], response['location']['lng'], response['accuracy']
开发者ID:nomoketo,项目名称:python-geolocate,代码行数:35,代码来源:geolocate.py
示例18: ScanForNetworks
def ScanForNetworks(self):
cells = Cell.all(WIRELESS)
listOfCells = []
for cell in cells:
if str(cell.ssid) not in listOfCells:
listOfCells.append(str(cell.ssid))
return(listOfCells)
开发者ID:codylallen,项目名称:ece477,代码行数:7,代码来源:Wifi.py
示例19: __init__
def __init__(self):
'''
Constructor method
'''
# Default directory & interface
self.cwd = os.getcwd()
self.iface = 'wlan0'
# Try to get wireless gateway details,
# unless there's no active connection
try:
self.ping_ip, self.gw_mac = self.getGateway()
except:
self.ping_ip = self.gw_mac = None
print('Error! \nCheck your connection!')
finally:
pass
# Get the Gateway SSID
try:
cell = Cell.all(self.iface)
x, y = str(list(cell)[0]).split('=')
self.ssid = y.strip(')')
except:
self.ssid = 'Offline'
开发者ID:k1nk33,项目名称:WiFi-Sniffer,代码行数:26,代码来源:NetUtil.py
示例20: run
def run(self):
#try:
#print Cell.all(self.interface)[0]
cell = Cell.all(self.interface)[0]
scheme = Scheme.for_cell(self.interface, self.ssid, cell, self.passphrase)
#scheme.save()
self._return = scheme.activate()
开发者ID:MycroftAI,项目名称:rpi3-headless-wifi-setup,代码行数:7,代码来源:LinkUtils.py
注:本文中的wifi.Cell类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论