Search code examples
pythonwifi

wifi: Scheme.for_cell fails with TypeError


Using the wifi package, here is what I did:

>>> cell = Cell.all('wlan0')[0]
>>> print cell
>>> scheme = Scheme.for_cell('wlan0', 'home', cell)

When I print cell it prints the ssid. When I run scheme = Scheme.for_cell('wlan0', 'home', cell). It gives the error

>>> scheme = Scheme.for_cell('wlan0', 'home', cell)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/aaeronn/virt_proj/wifi_hack/local/lib/python2.7/site-packages/wifi/scheme.py", line 110, in for_cell
    return cls(interface, name, configuration(cell, passkey))
  File "/home/aaeronn/virt_proj/wifi_hack/local/lib/python2.7/site-packages/wifi/scheme.py", line 23, in configuration
    if len(passkey) != 64:
TypeError: object of type 'NoneType' has no len()

Whats wrong ? Where should I enter the password for that ssid?


Solution

  • The documentation for wifi.Scheme.for_cell says it takes a passkey argument:

    classmethod for_cell(interface, name, cell, passkey=None)

    So with some passkey, you would call

    scheme = Scheme.for_cell('wlan0', 'home', cell, passkey)
    

    Looking at the source code for that package, the TypeError raised there is a bug, or at least a sign of hasty design.