本文整理汇总了Python中pythonwifi.iwlibs.Wireless类的典型用法代码示例。如果您正苦于以下问题:Python Wireless类的具体用法?Python Wireless怎么用?Python Wireless使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Wireless类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: checkwifi
def checkwifi():
#here is some trickery to work in windows
#without making a cmd window pop up frequently
startupinfo = None
print "os.name=="+OSName
if OSName == 'nt' or OSName =="win32": #the user is using windows so we don't want cmd to show
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
output = subprocess.Popen(["ipconfig", "/all"], stdout=subprocess.PIPE,
startupinfo=startupinfo).communicate()[0]
e=0
lines=output.split('\n')
for line in lines:
if line.startswith(' Connection-specific DNS Suffix . : '):
if not len(line)==40:
nline=line[39:]
print(line)
if "dublinschool.org" in nline:
if(not lines[e-3].startswith('Tunnel')): #make sure this is not a tunnel adapter
print('found')
return(True)
e=e+1; #maybe cleanup later
elif SYSPlat == 'linux2':
from pythonwifi.iwlibs import Wireless
wifi = Wireless('wlan0')
if(wifi.getEssid()=="student"):
return(True)
开发者ID:aggendo,项目名称:Dublin-Autologin,代码行数:27,代码来源:login.py
示例2: collectDataForInterface
def collectDataForInterface(self, iface):
w = Wireless(iface)
wsconfig = { }
simpleConfigs = (
("essid", w.getEssid, "off"),
("frequency", w.getFrequency, ""),
("accesspoint", w.getAPaddr, "Not-Associated"),
("bitrate", w.getBitrate, "0"),
("encryption", w.getEncryption, "off"),
)
for name, func, default in simpleConfigs:
try:
wsconfig[name] = func()
except:
wsconfig[name] = default
try:
wsconfig["quality"] = str(Iwstats("wlan0").qual.quality) + "/" + str(w.getQualityMax().quality)
except:
wsconfig["quality"] = ""
try:
wsconfig["signal"] = str(w.getQualityAvg().siglevel-128) + " dBm"
except:
wsconfig["signal"] = ""
return wsconfig
开发者ID:popazerty,项目名称:beyonwiz-4.1,代码行数:27,代码来源:Wlan.py
示例3: sniff_wifi
def sniff_wifi():
if plat == "OSX":
# bridge to objective c(apple stuff)
objc.loadBundle(
"CoreWLAN", bundle_path="/System/Library/Frameworks/CoreWLAN.framework", module_globals=globals()
)
for iname in CWInterface.interfaceNames():
interface = CWInterface.interfaceWithName_(iname)
wifi_parameters = (
"Interface: %s, SSID: %s, Transmit Rate: %s, Transmit Power: %s, RSSI: %s"
% (iname, interface.ssid(), interface.transmitRate(), interface.transmitPower(), interface.rssi())
)
elif plat == "LINUX":
interface = Wireless("wlan0")
# Link Quality, Signal Level and Noise Level line
wifi_parameters = "Interface: %s, SSID: %s, Transmit Rate: %s, Transmit Power: %s" % (
"wlan0",
interface.getEssid(),
interface.getBitrate(),
interface.getTXPower(),
)
# record wifi parameters
print wifi_parameters
open(channels_file, "a").write(wifi_parameters + "\n")
开发者ID:baharxy,项目名称:LTEWiFi-Measurements,代码行数:27,代码来源:udp_local_phone.py
示例4: main
def main():
rospy.init_node('wifi_poller')
poll_freq = rospy.get_param('~poll_freq', 1)
interface = rospy.get_param('~interface', 'eth1')
frame_id = rospy.get_param('~frame_id', 'base_link')
pub = rospy.Publisher('wifi_info', WifiInfo)
wifi = Wireless(interface)
poll_rate = rospy.Rate(poll_freq)
while not rospy.is_shutdown():
info = WifiInfo()
info.header.stamp = rospy.Time.now()
info.header.frame_id = frame_id
try:
info.essid = wifi.getEssid()
info.interface = interface
info.status = WifiInfo.STATUS_DISCONNECTED
if info.essid:
info.frequency = float(wifi.getFrequency().split(' ')[0])
info.APaddr = wifi.getAPaddr()
info.status = WifiInfo.STATUS_CONNECTED
except IOError:
# This can happen with an invalid iface
info.status = WifiInfo.STATUS_ERROR
except Exception, e:
info.status = WifiInfo.STATUS_ERROR
rospy.logerr('Error: %s' % e)
pub.publish(info)
poll_rate.sleep()
开发者ID:OSUrobotics,项目名称:wifi_info,代码行数:32,代码来源:poll_wifi.py
示例5: get_status
def get_status(interface):
interface = Wireless(interface)
try:
stats = Iwstats(interface)
except IOError:
return (None, None)
quality = stats.qual.quality
essid = interface.getEssid()
return (essid, quality)
开发者ID:20after4,项目名称:qtile,代码行数:9,代码来源:wlan.py
示例6: update
def update(self):
interface = Wireless(self.interface)
stats = Iwstats(self.interface)
quality = stats.qual.quality
essid = interface.getEssid()
text = "{} {}/70".format(essid, quality)
if self.text != text:
self.text = text
self.bar.draw()
return True
开发者ID:Cadair,项目名称:qtile,代码行数:10,代码来源:wlan.py
示例7: poll
def poll(self):
interface = Wireless(self.interface)
try:
stats = Iwstats(self.interface)
quality = stats.qual.quality
essid = interface.getEssid()
return "{} {}/70".format(essid, quality)
except IOError:
logging.getLogger('qtile').error('%s: Probably your wlan device '
'is switched off or otherwise not present in your system.',
self.__class__.__name__)
开发者ID:Davidbrcz,项目名称:qtile,代码行数:11,代码来源:wlan.py
示例8: getSignalLevel
def getSignalLevel(self):
wifi = Wireless('wlan1')
essid = wifi.getEssid()
signal = "xx"
try:
signal = wifi.getQualityAvg().signallevel
self.signalLevel.setValue(signal)
except:
pass
self.signalLevel.setFormat(str(essid)+" "+str(signal))
return True
开发者ID:homoludens,项目名称:py_examples,代码行数:11,代码来源:pyqtwindow.py
示例9: updateStates
def updateStates(self):
try:
wifi = Wireless('wlan0')
ap_addr = wifi.getAPaddr()
# Update Wifi Status
if (ap_addr == "00:00:00:00:00:00"):
self.ui.lblWifiStatus.setText('Not associated')
else:
self.ui.lblWifiStatus.setText(str(wifi.getEssid())+" connected")
# Update 3G status
## Grep for route here
# Update internet connectivity status
response = os.system("ping -c 1 google.co.uk > /dev/null")
if response == 0:
self.ui.lblNetStatus.setText('Connected')
netConnected = 1
else:
self.ui.lblNetStatus.setText('Not Connected')
netConnected = 0
# Update chef status
response = os.system("ps auwwwx | grep -q chef-client")
if response == 1:
self.ui.lblChefRunStatus.setText('Running...')
else:
self.ui.lblChefRunStatus.setText('Not Running')
try:
f = open('/tmp/chef-lastrun')
self.ui.lblChefStatus.setText(f.read())
f.close()
except:
self.ui.lblChefStatus.setText('Unable to read')
if netConnected:
self.launchTimer = self.launchTimer - 1
self.ui.btnLaunch.setEnabled(True)
else:
self.launchTimer = 15
self.ui.btnLaunch.setEnabled(False)
if self.launchTimer == 0:
self.LoginForm = LoginForm()
self.LoginForm.show()
self.hide()
self.ui.btnLaunch.setText("Launch ("+str(self.launchTimer)+")")
finally:
QtCore.QTimer.singleShot(1000, self.updateStates)
开发者ID:Afterglow,项目名称:pycar,代码行数:52,代码来源:pycar.py
示例10: paintInterface
def paintInterface(self, painter, option, rect):
wifi=Wireless('wlan0')
dump,qual,dump,dump=wifi.getStatistics()
self.chart.addSample([qual.signallevel-qual.noiselevel,qual.quality,100+qual.signallevel])
self.chart.setShowTopBar(False)
self.chart.setShowVerticalLines(False)
self.chart.setShowHorizontalLines(False)
self.chart.setShowLabels(False)
self.chart.setStackPlots(False)
self.chart.setUseAutoRange(True)
painter.save()
painter.setPen(Qt.black)
self.label.setText("ESSID: %s\nLink quality: %02d/100\nSignal level: %02ddB\nSignal/Noise: %02ddB"%(wifi.getEssid(),qual.quality,qual.signallevel,qual.signallevel-qual.noiselevel))
painter.restore()
开发者ID:nightsh,项目名称:argent-kde-config,代码行数:14,代码来源:main.py
示例11: get_intf_details
def get_intf_details(self, ip):
rnode = self._radix.search_best(ip)
intf = rnode.data["intf"]
wifi = Wireless(intf)
res = wifi.getEssid()
if type(res) is tuple:
dst_mac = ""
if rnode.data["gw"] == "0.0.0.0":
dst_mac = self._lookup_mac(ip)
# print "the ns %s has a mac %s"%(ip, dst_mac)
else:
dst_mac = self._lookup_mac(rnode.data["gw"])
# print "the gw %s has a mac %s"%(rnode.ata['gw'], dst_mac)
return dict(is_wireless=False, dst_mac=dst_mac, intf=intf, essid="", ns=ip)
else:
return dict(is_wireless=True, dst_mac=wifi.getAPaddr(), intf=intf, essid=res, ns=ip)
开发者ID:avsm,项目名称:signpost,代码行数:16,代码来源:routing.py
示例12: __init__
class WifiNodes:
def __init__(self, ifname):
self.nodes = {}
self.wifi = Wireless(ifname)
def addNode(self, mac, lvl, id=99):
# if it already exists
if id in self.nodes.keys():
if mac in self.nodes[id].keys():
if (lvl < self.nodes[id][mac]["min"]):
self.nodes[id][mac]["min"] = lvl
if (lvl > self.nodes[id][mac]["max"]):
self.nodes[id][mac]["max"] = lvl
else:
self.nodes[id][mac] = {"min": lvl, "max": lvl}
else:
self.nodes[id] = {mac: {"min": lvl, "max": lvl}}
def scan(self, id=99):
try:
results = self.wifi.scan()
except IOError, (error_number, error_string):
if error_number != errno.EPERM:
sys.stderr.write(
"%-8.16s Interface doesn't support scanning : %s\n\n" %
(self.wifi.ifname, error_string))
else:
开发者ID:ksami,项目名称:cg3002py,代码行数:27,代码来源:scan.py
示例13: queryWirelessDevice
def queryWirelessDevice(self,iface):
try:
from pythonwifi.iwlibs import Wireless
import errno
except ImportError:
return False
else:
try:
ifobj = Wireless(iface) # a Wireless NIC Object
wlanresponse = ifobj.getAPaddr()
except IOError, (error_no, error_str):
if error_no in (errno.EOPNOTSUPP, errno.ENODEV, errno.EPERM):
return False
else:
print "error: ",error_no,error_str
return True
else:
开发者ID:TangoCash,项目名称:tangos-enigma2,代码行数:17,代码来源:NetworkSetup.py
示例14: sniff_wifi
def sniff_wifi():
if plat=='OSX':
# bridge to objective c(apple stuff)
objc.loadBundle('CoreWLAN',
bundle_path='/System/Library/Frameworks/CoreWLAN.framework',
module_globals=globals())
for iname in CWInterface.interfaceNames():
interface = CWInterface.interfaceWithName_(iname)
wifi_parameters= 'Interface: %s, SSID: %s, Transmit Rate: %s, Transmit Power: %s, RSSI: %s' % (iname, interface.ssid(), interface.transmitRate(), interface.transmitPower(), interface.rssi())
elif plat=='LINUX':
interface=Wireless('wlan1')
stat, qual, discard, missed_beacon = interface.getStatistics()
# Link Quality, Signal Level and Noise Level line
wifi_parameters= 'Interface: %s, SSID: %s, Transmit Rate: %s, Transmit Power: %s, RSSI: %s' % ('wlan1', interface.getEssid(), interface.getBitrate(), interface.getTXPower(), qual.signallevel)
#record wifi parameters
print wifi_parameters
open(channels_file, "a").write(wifi_parameters+'\n')
开发者ID:baharxy,项目名称:LTEWiFi-Measurements,代码行数:19,代码来源:udp_local.py
示例15: topTen
def topTen(clazz):
IOCapture.startCapture()
networks = []
try:
for i in getNICnames():
w = Wireless(i)
networks.extend(w.scan())
finally:
IOCapture.stopCapture()
networks.sort(lambda a,b: cmp(a.quality.quality, b.quality.quality),
None, True)
print "Networks sorted by probable proximity"
for network in enumerate(networks):
print ' %s) %s (%s, %s)' % (network[0], network[1].essid,
network[1].quality.siglevel,
network[1].quality.quality)
开发者ID:ZachGoldberg,项目名称:AutoRemote,代码行数:21,代码来源:wifiloc.py
示例16: getNetworkList
def getNetworkList(self):
if self.oldInterfaceState is None:
self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
if self.oldInterfaceState is False:
if iNetwork.getAdapterAttribute(self.iface, "up") is False:
iNetwork.setAdapterAttribute(self.iface, "up", True)
system("ifconfig " + self.iface + " up")
ifobj = Wireless(self.iface) # a Wireless NIC Object
try:
scanresults = ifobj.scan()
except:
scanresults = None
print "[Wlan.py] No wireless networks could be found"
aps = {}
if scanresults is not None:
(num_channels, frequencies) = ifobj.getChannelInfo()
index = 1
for result in scanresults:
bssid = result.bssid
if result.encode.flags & wififlags.IW_ENCODE_DISABLED > 0:
encryption = False
elif result.encode.flags & wififlags.IW_ENCODE_NOKEY > 0:
encryption = True
else:
encryption = None
signal = str(result.quality.siglevel - 0x100) + " dBm"
quality = "%s/%s" % (result.quality.quality, ifobj.getQualityMax().quality)
extra = []
for element in result.custom:
element = element.encode()
extra.append(strip(self.asciify(element)))
for element in extra:
if "SignalStrength" in element:
signal = element[element.index("SignalStrength") + 15 : element.index(",L")]
if "LinkQuality" in element:
quality = element[element.index("LinkQuality") + 12 : len(element)]
# noinspection PyProtectedMember
aps[bssid] = {
"active": True,
"bssid": result.bssid,
"channel": frequencies.index(ifobj._formatFrequency(result.frequency.getFrequency())) + 1,
"encrypted": encryption,
"essid": strip(self.asciify(result.essid)),
"iface": self.iface,
"maxrate": ifobj._formatBitrate(result.rate[-1][-1]),
"noise": "", # result.quality.nlevel-0x100,
"quality": str(quality),
"signal": str(signal),
"custom": extra,
}
index += 1
return aps
开发者ID:OUARGLA86,项目名称:enigma2,代码行数:59,代码来源:Wlan.py
示例17: getNetworkList
def getNetworkList(self):
if self.oldInterfaceState is None:
self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
if self.oldInterfaceState is False:
if iNetwork.getAdapterAttribute(self.iface, "up") is False:
iNetwork.setAdapterAttribute(self.iface, "up", True)
enigma.eConsoleAppContainer().execute("ifconfig %s up" % self.iface)
ifobj = Wireless(self.iface) # a Wireless NIC Object
try:
scanresults = ifobj.scan()
except:
scanresults = None
print "[Wlan.py] No wireless networks could be found"
aps = {}
if scanresults is not None:
(num_channels, frequencies) = ifobj.getChannelInfo()
index = 1
for result in scanresults:
bssid = result.bssid
if result.encode.flags & wififlags.IW_ENCODE_DISABLED > 0:
encryption = False
elif result.encode.flags & wififlags.IW_ENCODE_NOKEY > 0:
encryption = True
else:
encryption = None
signal = str(result.quality.siglevel-0x100) + " dBm"
quality = "%s/%s" % (result.quality.quality,ifobj.getQualityMax().quality)
extra = []
for element in result.custom:
element = element.encode()
extra.append( strip(self.asciify(element)) )
for element in extra:
if 'SignalStrength' in element:
signal = element[element.index('SignalStrength')+15:element.index(',L')]
if 'LinkQuality' in element:
quality = element[element.index('LinkQuality')+12:len(element)]
# noinspection PyProtectedMember
aps[bssid] = {
'active' : True,
'bssid': result.bssid,
'channel': frequencies.index(ifobj._formatFrequency(result.frequency.getFrequency())) + 1,
'encrypted': encryption,
'essid': strip(self.asciify(result.essid)),
'iface': self.iface,
'maxrate' : ifobj._formatBitrate(result.rate[-1][-1]),
'noise' : '',#result.quality.nlevel-0x100,
'quality' : str(quality),
'signal' : str(signal),
'custom' : extra,
}
index += 1
return aps
开发者ID:dazulrich,项目名称:dvbapp,代码行数:59,代码来源:Wlan.py
示例18: getNetworkList
def getNetworkList(self):
system("ifconfig "+self.iface+" up")
ifobj = Wireless(self.iface) # a Wireless NIC Object
#Association mappings
#stats, quality, discard, missed_beacon = ifobj.getStatistics()
#snr = quality.signallevel - quality.noiselevel
try:
scanresults = ifobj.scan()
except:
scanresults = None
print "[Wlan.py] No Wireless Networks could be found"
if scanresults is not None:
aps = {}
(num_channels, frequencies) = ifobj.getChannelInfo()
index = 1
for result in scanresults:
bssid = result.bssid
if result.encode.flags & wififlags.IW_ENCODE_DISABLED > 0:
encryption = False
elif result.encode.flags & wififlags.IW_ENCODE_NOKEY > 0:
encryption = True
else:
encryption = None
signal = str(result.quality.siglevel-0x100) + " dBm"
quality = "%s/%s" % (result.quality.quality,ifobj.getQualityMax().quality)
extra = []
for element in result.custom:
element = element.encode()
extra.append( strip(self.asciify(element)) )
for element in extra:
print element
if 'SignalStrength' in element:
signal = element[element.index('SignalStrength')+15:element.index(',L')]
if 'LinkQuality' in element:
quality = element[element.index('LinkQuality')+12:len(element)]
aps[bssid] = {
'active' : True,
'bssid': result.bssid,
'channel': frequencies.index(ifobj._formatFrequency(result.frequency.getFrequency())) + 1,
'encrypted': encryption,
'essid': strip(self.asciify(result.essid)),
'iface': self.iface,
'maxrate' : ifobj._formatBitrate(result.rate[-1][-1]),
'noise' : '',#result.quality.nlevel-0x100,
'quality' : str(quality),
'signal' : str(signal),
'custom' : extra,
}
#print "GOT APS ENTRY:",aps[bssid]
index = index + 1
return aps
开发者ID:FFTEAM,项目名称:enigma2-5,代码行数:58,代码来源:Wlan.py
示例19: ScanAp
def ScanAp( self, aDev ) :
from pythonwifi.iwlibs import Wireless
import pythonwifi.flags
status = None
try :
scanResult = None
if GetCurrentNetworkType( ) != NETWORK_WIRELESS :
os.system( 'ifup %s' % aDev )
wifi = Wireless( aDev )
scanResult = wifi.scan( )
if scanResult != None :
apList = []
for ap in scanResult :
if len( ap.essid ) > 0 :
apInfoList = []
apInfoList.append( ap.essid )
apInfoList.append( ap.quality.getSignallevel( ) )
if ap.encode.flags & pythonwifi.flags.IW_ENCODE_DISABLED :
apInfoList.append( 'No' )
else :
apInfoList.append( 'Yes' )
apList.append( apInfoList )
if apList :
status = apList
else :
status = None
if GetCurrentNetworkType( ) != NETWORK_WIRELESS :
os.system( 'ifdown %s' % aDev )
return status
except Exception, e :
LOG_ERR( 'Error exception[%s]' % e )
if GetCurrentNetworkType( ) != NETWORK_WIRELESS :
os.system( 'ifdown %s' % aDev )
status = None
return status
开发者ID:OpenPrismCube,项目名称:script.mbox,代码行数:38,代码来源:IpParser.py
示例20: run
def run(self):
"""
run the plugin
"""
current_targets = set()
logging.debug(str(self.__class__) + " Scanning for wlan devices")
try:
wifi = Wireless( self._pcc.get_cfg("wlan_device") )
results = wifi.scan()
except IOError:
raise PermissionDenied("Cannot scan for wifi :(")
sys.exit(1)
if len(results) > 0:
for ap in results:
# print ap.bssid + " " + frequencies.index(wifi._formatFrequency(ap.frequency.getFrequency())) + " " + ap.essid + " " + ap.quality.getSignallevel()
target = airxploit.core.target.Wlan()
target.quality = ap.quality.getSignallevel()
target.name = ap.essid
target.addr = ap.bssid
target.channel = WlanScanner.frequency_channel_map.get( ap.frequency.getFrequency() )
current_targets.add(target)
logging.debug(str(self.__class__) + " Found wlan device " + ap.bssid + " " + " " + ap.essid)
if self.result == current_targets:
got_new_targets = False
else:
got_new_targets = True
if got_new_targets:
for target in current_targets:
if target not in self.result:
self._pcc.add_target( target )
self.result = current_targets
self._pcc.fire_event(WlanScanner.EVENT)
开发者ID:DeveloperVox,项目名称:airxploit,代码行数:37,代码来源:wlan.py
注:本文中的pythonwifi.iwlibs.Wireless类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论