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


Python iwlibs.Wireless类代码示例

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


在下文中一共展示了Wireless类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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