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


Python Wireless.scan方法代码示例

本文整理汇总了Python中pythonwifi.iwlibs.Wireless.scan方法的典型用法代码示例。如果您正苦于以下问题:Python Wireless.scan方法的具体用法?Python Wireless.scan怎么用?Python Wireless.scan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pythonwifi.iwlibs.Wireless的用法示例。


在下文中一共展示了Wireless.scan方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from pythonwifi.iwlibs import Wireless [as 别名]
# 或者: from pythonwifi.iwlibs.Wireless import scan [as 别名]
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,代码行数:29,代码来源:scan.py

示例2: getNetworkList

# 需要导入模块: from pythonwifi.iwlibs import Wireless [as 别名]
# 或者: from pythonwifi.iwlibs.Wireless import scan [as 别名]
	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,代码行数:61,代码来源:Wlan.py

示例3: getNetworkList

# 需要导入模块: from pythonwifi.iwlibs import Wireless [as 别名]
# 或者: from pythonwifi.iwlibs.Wireless import scan [as 别名]
    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,代码行数:61,代码来源:Wlan.py

示例4: getNetworkList

# 需要导入模块: from pythonwifi.iwlibs import Wireless [as 别名]
# 或者: from pythonwifi.iwlibs.Wireless import scan [as 别名]
	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,代码行数:60,代码来源:Wlan.py

示例5: topTen

# 需要导入模块: from pythonwifi.iwlibs import Wireless [as 别名]
# 或者: from pythonwifi.iwlibs.Wireless import scan [as 别名]
  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,代码行数:23,代码来源:wifiloc.py

示例6: ScanAp

# 需要导入模块: from pythonwifi.iwlibs import Wireless [as 别名]
# 或者: from pythonwifi.iwlibs.Wireless import scan [as 别名]
	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,代码行数:40,代码来源:IpParser.py

示例7: run

# 需要导入模块: from pythonwifi.iwlibs import Wireless [as 别名]
# 或者: from pythonwifi.iwlibs.Wireless import scan [as 别名]
    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,代码行数:39,代码来源:wlan.py

示例8: Scanner

# 需要导入模块: from pythonwifi.iwlibs import Wireless [as 别名]
# 或者: from pythonwifi.iwlibs.Wireless import scan [as 别名]
class Scanner():
    def __init__(self, wireless, x=0, y=0):
        self.w=Wireless(wireless)
        self.rm=None
        self.x=x
        self.y=y
        self.aps={}

    def init_launcher(self):
        self.rm=RocketManager()
        self.rm.acquire_devices()

    def step(self,dir,steps=1, sane=False):
        if not self.rm: self.init_launcher()
        c=0
        while c<steps:
            if dir==RIGHT:
                if sane or self.x>0: self.x-=1
                else: break
            elif dir==LEFT:
                if sane or self.x<HMAX: self.x+=1
                else: break
            elif dir==UP:
                if sane or self.y<VMAX: self.y+=1
                else: break
            elif dir==DOWN:
                if sane or self.y>0: self.y-=1
                else: break
            self.rm.launchers[0].start_movement(dir)
            self.rm.launchers[0].stop_movement()
            c+=1
        if c==steps:
            return True

    def home(self):
        if not self.rm: self.init_launcher()
        print "press c-c when in home position"
        while True:
            print s.x
            try:
                s.step(RIGHT,steps=200, sane=True)
            except KeyboardInterrupt:
                self.rm.launchers[0].stop_movement()
                sys.exit(0)

    def scan(self,c=1, cb=None):
        res=[]
        for _ in xrange(c):
            tmp=[]
            for h in self.w.scan():
                try:
                    name=h.essid.decode('utf8')
                except:
                    name=h.bssid
                # TODO add
                # "Quality: Quality ", self.quality.quality
                # "Signal ", self.quality.getSignallevel()
                # "Noise ", self.quality.getNoiselevel()
                # "Encryption:", map(lambda x: hex(ord(x)), self.encode)
                # "Frequency:", self.frequency.getFrequency(), "(Channel", self.frequency.getChannel(self.range), ")"
                record=(self.x,
                        self.y,
                        datetime.now().isoformat(),
                        h.bssid,
                        h.quality.getSignallevel(),
                        name.strip())
                tmp.append(record)
            if cb: tmp=cb(tmp)
            res.extend(tmp)

        # handle callback
        for ap in res:
            # print all scan records
            print u' '.join([unicode(f) for f in ap])
            # remember all entries for later
            self.store(*ap)

        return res

    def store(self, x, y, date, bssid, rssi, name):
        try:
            self.aps[bssid]['rssi'].append((date, int(rssi), int(x), int(y)))
        except:
            self.aps[bssid]={'name': name.strip(),
                             'rssi': [(date, int(rssi), int(x), int(y))]}

    def fasth(self, c=1, steps=10, cb=None, sweeps=1):
        res=[]
        dirs=[LEFT, RIGHT]
        for i in xrange(sweeps):
            while True:
                aps=self.scan(c)
                if cb: aps=cb(aps)
                res.extend(aps)
                if not self.step(dirs[i%2],steps):
                    break
            if self.y==0:
                self.movetoy(VMAX)
            else:
                self.movetoy(0)
#.........这里部分代码省略.........
开发者ID:0x90,项目名称:wireless-radar,代码行数:103,代码来源:wscan.py

示例9: Wireless

# 需要导入模块: from pythonwifi.iwlibs import Wireless [as 别名]
# 或者: from pythonwifi.iwlibs.Wireless import scan [as 别名]
    5320000000: "64",
    5500000000: "100",
    5520000000: "104",
    5540000000: "108",
    5560000000: "112",
    5580000000: "116",
    5600000000: "120",
    5620000000: "124",
    5640000000: "128",
    5660000000: "132",
    5680000000: "136",
    5700000000: "140",
    5735000000: "147",
    5755000000: "151",
    5775000000: "155",
    5795000000: "159",
    5815000000: "163",
    5835000000: "167",
    5785000000: "171"
}

wifi = Wireless("wlan0")

for ap in wifi.scan():
    print "SSID: " + ap.essid
    print "AP: " + ap.bssid
    print "Signal: " + str(ap.quality.getSignallevel())
    print "Frequency: " + str(ap.frequency.getFrequency())
    print "Channel: " + frequency_channel_map.get(ap.frequency.getFrequency())
    print ""
开发者ID:Cergoo,项目名称:junk,代码行数:32,代码来源:wlan-scanner.py


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