Beispiel #1
0
def main():
    # if only program name is given, print usage info
    if len(sys.argv) == 1:
        usage()

    # if program name and one argument are given
    if len(sys.argv) == 2:
        option = sys.argv[1]
        # look for matching command
        list_command = get_matching_command(option)
        # if the one argument is a command
        if list_command is not None:
            for ifname in getNICnames():
                wifi = Wireless(ifname)
                list_command(wifi)
        else:
            print("iwlist.py: unknown command `%s' " \
                  "(check 'iwlist.py --help')." % (option, ))

    # if program name and more than one argument are given
    if len(sys.argv) > 2:
        # Get the interface and command from command line
        ifname, option = sys.argv[1:]
        # look for matching command
        list_command = get_matching_command(option)
        # if the second argument is a command
        if list_command is not None:
            wifi = Wireless(ifname)
            list_command(wifi, sys.argv[3:])
        else:
            print("iwlist.py: unknown command `%s' " \
                   "(check 'iwlist.py --help')." % (option, ))
Beispiel #2
0
def main():
    # if only program name is given, print usage info
    if len(sys.argv) == 1:
        usage()

    # if program name and one argument are given
    if len(sys.argv) == 2:
        option = sys.argv[1]
        # look for matching command
        list_command = get_matching_command(option)
        # if the one argument is a command
        if list_command is not None:
            for ifname in getNICnames():
                wifi = Wireless(ifname)
                list_command(wifi)
        else:
            print "iwlist.py: unknown command `%s' " "(check 'iwlist.py --help')." % (option,)

    # if program name and more than one argument are given
    if len(sys.argv) > 2:
        # Get the interface and command from command line
        ifname, option = sys.argv[1:]
        # look for matching command
        list_command = get_matching_command(option)
        # if the second argument is a command
        if list_command is not None:
            wifi = Wireless(ifname)
            list_command(wifi, sys.argv[3:])
        else:
            print "iwlist.py: unknown command `%s' " "(check 'iwlist.py --help')." % (option,)
Beispiel #3
0
  def __init__(self):
    try:
        self.interfaces = getNICnames()
    except:
        self.interfaces = []

    self.known_networks = {}
    self.wifis = []
    for i in self.interfaces:
      self.wifis.append(Wireless(i))
Beispiel #4
0
def main():
    try:
        opts, args = getopt.getopt(sys.argv[1:], "hv", ["help", "version"])
    except getopt.GetoptError as error:
        # invalid options will be taken to be interface name
        print(error)
    else:
        try:
            if opts[0][0] in ("-h", "--help"):
                usage()
        except:
            try:
                if opts[0][0] in ("-v", "--version"):
                    version_info()
            except:
                if len(args) == 0:
                    # no params given to iwconfig.py
                    for interface in getNICnames():
                        iwconfig(interface)
                elif len(args) == 1:
                    # one param given to iwconfig.py, it should be a network device
                    if sys.argv[1] in getNICnames():
                        iwconfig(sys.argv[1])
                else:
                    # more than one param, must be a command
                    # if program name and more than one argument are given
                    if len(sys.argv) > 2:
                        # Get the interface and command from command line
                        ifname, option = sys.argv[1:3]
                        # look for matching command
                        set_command = get_matching_command(option)
                        # if the second argument is a command
                        if set_command is not None:
                            wifi = Wireless(ifname)
                            set_command(wifi, sys.argv[3])
                        else:
                            print "iwconfig.py: unknown command `%s' " \
                                "(check 'iwconfig.py --help')." % (option, )
Beispiel #5
0
  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)
Beispiel #6
0
 def setUp(self):
     ifnames = getNICnames()
     self.wifi = Wireless(ifnames[0])
Beispiel #7
0
 def vars(self):
     return iwlibs.getNICnames()
Beispiel #8
0
def checkinterface(wif):
    found = False
    for iface in getNICnames():
        if iface == wif:
            found = True
    return found
Beispiel #9
0
import sys, os.path
from optparse import OptionParser
from pythonwifi.iwlibs import Wireless, getNICnames
import wx
from wx.lib.floatcanvas import NavCanvas, FloatCanvas

# floorplan = 'carlland.jpg'
# datafile = 'carlland.dat'

parser = OptionParser()
parser.add_option("-f", dest="floorplan", default="floorplan.png",
                  help="Image file to use for the floor plan.")
parser.add_option("-d", dest="datafile", 
                  help="Data file to write to. (defaults to <floorplan>.dat)")

ifaces=getNICnames()
iface=ifaces[0]
parser.add_option("-i", dest="ifname", choices=ifaces, default=iface,
                  help="interface. (defaults to first wifi device: %s)"% iface)
 
(options, args) = parser.parse_args()

# construct a datafile name from image name
if not options.datafile:
    options.datafile = os.path.splitext(options.floorplan)[0]+'.dat'

def wifidata(iface):
    """
    return a list of data about the current wifi conditions.
    """
    stat, qual, discard, missed_beacon = iface.getStatistics()
Beispiel #10
0
     opts, args = getopt.getopt(sys.argv[1:], "hv", ["help", "version"])
 except getopt.GetoptError, error_str:
     # invalid options will be taken to be interface name
     pass
 else:
     try:
         if opts[0][0] in ("-h", "--help"):
             usage()
     except:
         try:
             if opts[0][0] in ("-v", "--version"):
                 version_info()
         except:
             if len(args) == 0:
                 # no params given to iwconfig.py
                 for interface in getNICnames():
                     iwconfig(interface)
             elif len(args) == 1:
                 # one param given to iwconfig.py, it should be a network device
                 if sys.argv[1] in getNICnames():
                     iwconfig(sys.argv[1])
             else:
                 # more than one param, must be a command
                 # if program name and more than one argument are given
                 if len(sys.argv) > 2:
                     # Get the interface and command from command line
                     ifname, option = sys.argv[1:3]
                     # look for matching command
                     set_command = get_matching_command(option)
                     # if the second argument is a command
                     if set_command is not None:
Beispiel #11
0
def get_interface():
    return getNICnames()
Beispiel #12
0
import wx
from wx.lib.floatcanvas import NavCanvas, FloatCanvas

# floorplan = 'carlland.jpg'
# datafile = 'carlland.dat'

parser = OptionParser()
parser.add_option("-f",
                  dest="floorplan",
                  default="floorplan.png",
                  help="Image file to use for the floor plan.")
parser.add_option("-d",
                  dest="datafile",
                  help="Data file to write to. (defaults to <floorplan>.dat)")

ifaces = getNICnames()
iface = ifaces[0]
parser.add_option("-i",
                  dest="ifname",
                  choices=ifaces,
                  default=iface,
                  help="interface. (defaults to first wifi device: %s)" %
                  iface)

(options, args) = parser.parse_args()

# construct a datafile name from image name
if not options.datafile:
    options.datafile = os.path.splitext(options.floorplan)[0] + '.dat'

Beispiel #13
0
    """
    pass

def main():
    try:
        opts, args = getopt.getopt(sys.argv[1:], "hv", ["help", "version"])
    except getopt.GetoptError, error_str:
        # invalid options will be taken to be interface name
        pass
    else:
        try:
            if opts[0][0] in ("-h", "--help"):
                usage()
        except:
            try:
                if opts[0][0] in ("-v", "--version"):
                    version_info()
            except:
                if len(args) == 0:
                    # no params given to iwconfig.py
                    for interface in getNICnames():
                        iwconfig(interface)
                if len(args) == 1:
                    # one param given to iwconfig.py, it should be a network device
                    if sys.argv[1] in getNICnames():
                        iwconfig(sys.argv[1])


if __name__ == "__main__":
    main()
Beispiel #14
0
 def vars(self):
     return iwlibs.getNICnames()