[Python-modules-commits] [wifi-python] 01/02: Import Upstream version 0.3.8

Ethan Ward ethanward-guest at moszumanska.debian.org
Sat Aug 12 00:13:52 UTC 2017


This is an automated email from the git hooks/post-receive script.

ethanward-guest pushed a commit to branch master
in repository wifi-python.

commit 5cee81f223ecfb6545d0c0061cfd0e4620c62c51
Author: Ethan Ward <ethan.ward at mycroft.ai>
Date:   Fri Aug 11 19:13:33 2017 -0500

    Import Upstream version 0.3.8
---
 CHANGES.rst                        | 100 +++++++++++++++++
 CONTRIBUTING.rst                   |  48 ++++++++
 LICENSE                            |  22 ++++
 MANIFEST.in                        |   3 +
 PKG-INFO                           | 140 +++++++++++++++++++++++
 README.rst                         |  17 +++
 bin/wifi                           | 205 ++++++++++++++++++++++++++++++++++
 extras/wifi-completion.bash        |  19 ++++
 setup.cfg                          |   5 +
 setup.py                           |  60 ++++++++++
 wifi.egg-info/PKG-INFO             | 140 +++++++++++++++++++++++
 wifi.egg-info/SOURCES.txt          |  19 ++++
 wifi.egg-info/dependency_links.txt |   1 +
 wifi.egg-info/requires.txt         |   2 +
 wifi.egg-info/top_level.txt        |   1 +
 wifi/__init__.py                   |   2 +
 wifi/exceptions.py                 |   6 +
 wifi/scan.py                       | 171 ++++++++++++++++++++++++++++
 wifi/scheme.py                     | 220 +++++++++++++++++++++++++++++++++++++
 wifi/subprocess_compat.py          |  63 +++++++++++
 wifi/utils.py                      |  57 ++++++++++
 21 files changed, 1301 insertions(+)

diff --git a/CHANGES.rst b/CHANGES.rst
new file mode 100644
index 0000000..b6c4d9a
--- /dev/null
+++ b/CHANGES.rst
@@ -0,0 +1,100 @@
+Changelog
+=========
+
+0.3.8
+^^^^^
+:release-date: 2016-03-11
+
+- Parse noise level if available (#91 - thanks zgoda-mobica)
+
+0.3.7
+^^^^^
+:release-date: 2016-03-11
+
+- Fix bugs related to scheme parsing (#59, #42)
+
+0.3.6
+^^^^^
+:release-date: 2016-02-11
+
+- Set all attributes to None in Cell.__init__ (#88 - thanks stvad)
+
+0.3.5
+^^^^^
+:release-date: 2016-01-24
+
+- Better password handling (#62 - thanks foosel)
+- Account for Cells with no SSID (#86 - thanks tlau)
+
+0.3.4
+^^^^^
+:release-date: 2014-09-02
+
+- Fixed installation missing some files (#48 - thanks luckydonald)
+
+0.3.3
+^^^^^
+:release-date: 2014-08-31
+
+- Check for write access for bashcompletion via os.access (#41, #47 - thanks foosel and jegger)
+- Fixed scanning when quality is reported absolutely (#45 - jeromelebel)
+- Fixed channel parsing (#33, #39 - thanks gavinwahl and qizha)
+
+0.3.2
+^^^^^
+:release-date: 2014-07-26
+
+- Only run if __name__ == '__main__' (#29 - thanks Jonwei)
+- Try to connect to the nearest Access Point
+- wifi scan was failing when Bit Rate was the last line of output (#42 - thanks jargij)
+- Added documentation for signal and quality on Cell
+
+0.3.1
+^^^^^
+:release-date: 2014-02-10
+
+- Scheme.activate was failing on a TypeError in Python3
+
+0.3.0
+^^^^^
+:release-date: 2014-02-09
+
+- Scheme.activate now throws a ConnectionError if activation failed (#17 - thanks alexykot)
+- Cell.all now throws an InterfaceError if scanning failed (#18 - thanks alexykot)
+- Better error message when scheme isn't found (#19 - thanks gavinwahl)
+- Added ability to delete schemes (#20 - thanks spektom)
+- Added the --file option (#21)
+- Scheme.activate returns a Connection object (#22)
+- Added the autoconnect command (#23)
+- Fixed parsing error missing channel (#24 - thanks LiorKirsch)
+- Fixed relative signal return as zero (#25 - thanks LiorKirsch)
+- Relative signals are now converted to dBm (#26 - thanks LiorKirsch)
+- Various codebase cleanup (#27 - thanks ramnes)
+- Added support for WPA Version 1 (#28 - thanks LiorKirsch)
+- Fixed Python3 support for WPA/PBKDF2
+
+0.2.2
+^^^^^
+:release-date: 2013-12-25
+
+- Fixed relative signal parsing bug (#12 - thanks alexykot)
+
+0.2.1
+^^^^^
+:release-date: 2013-11-22
+
+- Fixed print_table str/int bug (#13 - thanks DanLipsitt)
+
+0.2.0
+^^^^^
+:release-date: 2013-09-27
+
+- Added support for WEP
+- Fixed bug related to very short SSIDs
+- Fixed bug related to numeric passkeys
+
+0.1.1
+^^^^^
+:release-date: 2013-05-26
+
+- Updated setup.py to actually install the bash completion script
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
new file mode 100644
index 0000000..6b40549
--- /dev/null
+++ b/CONTRIBUTING.rst
@@ -0,0 +1,48 @@
+Contributing
+------------
+
+Please contribute!  You can contribute by making a pull request or reporting
+bugs.  You can also submit feature requests or ask questions about how to do
+things with wifi.
+
+How to Submit an Issue
+======================
+
+Issues include bug reports, feature requests, documentation requests, and lots
+of other things too.
+
+1.  Go to https://github.com/rockymeza/wifi/issues to see the issue tracker.
+
+2.  Please make sure that the issue hasn't already been opened by somebody
+    else.
+
+3.  Create a New Issue.  If it is a bug, please tell me what distro you are
+    using.  I don't have the capacity to test against a bunch of distros, but I
+    do want wifi to work on more than just the one that I use.
+
+How to Submit a Pull Request
+============================
+
+1.  Clone the repo.
+
+2.  Run the tests. ::
+
+       $ python setup.py test
+
+3.  Create a topic branch.
+
+4.  Make your awesome changes.
+
+    Don't forget to add tests to make sure that your awesome changes will
+    continue to work for all of eternity.
+
+5.  Make sure that your code conforms to PEP8 and the Zen of Python as much as
+    possible (ignore E501, the line lengths requirement).
+
+6.  Get on GitHub and submit a pull request.
+    
+The best pull requests will not have PEP8 errors and will include tests.  If
+you don't have tests, I am still willing to accept the pull request, but it may
+take a while for me to merge it as I would want to write the tests myself and I
+don't have a ton of time I can devote to that (especially during the school
+year).
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..432b131
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,22 @@
+Copyright (c) 2012, Gavin Wahl <gavinwahl at gmail.com>, Rocky Meza <rockymeza at gmail.com>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+   list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+softwARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..39e431d
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,3 @@
+include *.rst
+include LICENSE
+recursive-include extras *
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..b578bd1
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,140 @@
+Metadata-Version: 1.1
+Name: wifi
+Version: 0.3.8
+Summary: 
+Command line tool and library wrappers around iwlist and
+/etc/network/interfaces.
+
+Home-page: UNKNOWN
+Author: Rocky Meza, Gavin Wahl
+Author-email: rockymeza at gmail.com
+License: BSD
+Description: wifi
+        ----
+        
+        Wifi provides a command line wrapper for iwlist and /etc/network/interfaces
+        that makes it easier to connect the WiFi networks from the command line.  The
+        wifi command is also implemented as a library that can be used from Python.
+        
+        ::
+        
+            # pip install wifi
+            # wifi --help
+        
+        
+        .. image:: https://travis-ci.org/rockymeza/wifi.png?branch=master
+           :target: https://travis-ci.org/rockymeza/wifi
+        
+        The documentation for wifi lives at https://wifi.readthedocs.org/en/latest/.
+        
+        
+        Changelog
+        =========
+        
+        0.3.8
+        ^^^^^
+        :release-date: 2016-03-11
+        
+        - Parse noise level if available (#91 - thanks zgoda-mobica)
+        
+        0.3.7
+        ^^^^^
+        :release-date: 2016-03-11
+        
+        - Fix bugs related to scheme parsing (#59, #42)
+        
+        0.3.6
+        ^^^^^
+        :release-date: 2016-02-11
+        
+        - Set all attributes to None in Cell.__init__ (#88 - thanks stvad)
+        
+        0.3.5
+        ^^^^^
+        :release-date: 2016-01-24
+        
+        - Better password handling (#62 - thanks foosel)
+        - Account for Cells with no SSID (#86 - thanks tlau)
+        
+        0.3.4
+        ^^^^^
+        :release-date: 2014-09-02
+        
+        - Fixed installation missing some files (#48 - thanks luckydonald)
+        
+        0.3.3
+        ^^^^^
+        :release-date: 2014-08-31
+        
+        - Check for write access for bashcompletion via os.access (#41, #47 - thanks foosel and jegger)
+        - Fixed scanning when quality is reported absolutely (#45 - jeromelebel)
+        - Fixed channel parsing (#33, #39 - thanks gavinwahl and qizha)
+        
+        0.3.2
+        ^^^^^
+        :release-date: 2014-07-26
+        
+        - Only run if __name__ == '__main__' (#29 - thanks Jonwei)
+        - Try to connect to the nearest Access Point
+        - wifi scan was failing when Bit Rate was the last line of output (#42 - thanks jargij)
+        - Added documentation for signal and quality on Cell
+        
+        0.3.1
+        ^^^^^
+        :release-date: 2014-02-10
+        
+        - Scheme.activate was failing on a TypeError in Python3
+        
+        0.3.0
+        ^^^^^
+        :release-date: 2014-02-09
+        
+        - Scheme.activate now throws a ConnectionError if activation failed (#17 - thanks alexykot)
+        - Cell.all now throws an InterfaceError if scanning failed (#18 - thanks alexykot)
+        - Better error message when scheme isn't found (#19 - thanks gavinwahl)
+        - Added ability to delete schemes (#20 - thanks spektom)
+        - Added the --file option (#21)
+        - Scheme.activate returns a Connection object (#22)
+        - Added the autoconnect command (#23)
+        - Fixed parsing error missing channel (#24 - thanks LiorKirsch)
+        - Fixed relative signal return as zero (#25 - thanks LiorKirsch)
+        - Relative signals are now converted to dBm (#26 - thanks LiorKirsch)
+        - Various codebase cleanup (#27 - thanks ramnes)
+        - Added support for WPA Version 1 (#28 - thanks LiorKirsch)
+        - Fixed Python3 support for WPA/PBKDF2
+        
+        0.2.2
+        ^^^^^
+        :release-date: 2013-12-25
+        
+        - Fixed relative signal parsing bug (#12 - thanks alexykot)
+        
+        0.2.1
+        ^^^^^
+        :release-date: 2013-11-22
+        
+        - Fixed print_table str/int bug (#13 - thanks DanLipsitt)
+        
+        0.2.0
+        ^^^^^
+        :release-date: 2013-09-27
+        
+        - Added support for WEP
+        - Fixed bug related to very short SSIDs
+        - Fixed bug related to numeric passkeys
+        
+        0.1.1
+        ^^^^^
+        :release-date: 2013-05-26
+        
+        - Updated setup.py to actually install the bash completion script
+        
+Platform: Debian
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Topic :: System :: Networking
+Classifier: Operating System :: POSIX :: Linux
+Classifier: Environment :: Console
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3.3
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..30103ed
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,17 @@
+wifi
+----
+
+Wifi provides a command line wrapper for iwlist and /etc/network/interfaces
+that makes it easier to connect the WiFi networks from the command line.  The
+wifi command is also implemented as a library that can be used from Python.
+
+::
+
+    # pip install wifi
+    # wifi --help
+
+
+.. image:: https://travis-ci.org/rockymeza/wifi.png?branch=master
+   :target: https://travis-ci.org/rockymeza/wifi
+
+The documentation for wifi lives at https://wifi.readthedocs.org/en/latest/.
diff --git a/bin/wifi b/bin/wifi
new file mode 100755
index 0000000..140d437
--- /dev/null
+++ b/bin/wifi
@@ -0,0 +1,205 @@
+#!/usr/bin/python
+from __future__ import print_function
+import argparse
+import sys
+import os
+
+from wifi import Cell, Scheme
+from wifi.utils import print_table, match as fuzzy_match
+from wifi.exceptions import ConnectionError, InterfaceError
+
+try:  # Python 2.x
+    input = raw_input
+except NameError:
+    pass
+
+
+def fuzzy_find_cell(interface, query):
+    match_partial = lambda cell: fuzzy_match(query, cell.ssid)
+
+    matches = Cell.where(interface, match_partial)
+
+    num_unique_matches = len(set(cell.ssid for cell in matches))
+    assert num_unique_matches > 0, "Couldn't find a network that matches '{}'".format(query)
+    assert num_unique_matches < 2, "Found more than one network that matches '{}'".format(query)
+
+    # Several cells of the same SSID
+    if len(matches) > 1:
+        matches.sort(key=lambda cell: cell.signal)
+
+    return matches[0]
+
+
+def find_cell(interface, query):
+    cell = Cell.where(interface, lambda cell: cell.ssid.lower() == query.lower())
+
+    try:
+        cell = cell[0]
+    except IndexError:
+        cell = fuzzy_find_cell(interface, query)
+    return cell
+
+
+def get_scheme_params(interface, scheme, ssid=None):
+    cell = find_cell(interface, ssid or scheme)
+    passkey = None if not cell.encrypted else input('passkey> ')
+
+    return interface, scheme, cell, passkey
+
+
+def scan_command(args):
+    print_table([[cell.signal, cell.ssid, 'protected' if cell.encrypted else 'unprotected'] for cell in Cell.all(args.interface)])
+
+
+def list_command(args):
+    for scheme in Scheme.for_file(args.file).all():
+        print(scheme.name)
+
+
+def show_command(args):
+    scheme = Scheme.for_file(args.file).for_cell(*get_scheme_params(args.interface, args.scheme, args.ssid))
+    print(scheme)
+
+
+def add_command(args):
+    scheme_class = Scheme.for_file(args.file)
+    assert not scheme_class.find(args.interface, args.scheme), "That scheme has already been used"
+
+    scheme = scheme_class.for_cell(*get_scheme_params(args.interface, args.scheme, args.ssid))
+    scheme.save()
+
+
+def connect_command(args):
+    scheme_class = Scheme.for_file(args.file)
+    if args.adhoc:
+        # ensure that we have the adhoc utility scheme
+        try:
+            adhoc_scheme = scheme_class(args.interface, 'adhoc')
+            adhoc_scheme.save()
+        except AssertionError:
+            pass
+        except IOError:
+            assert False, "Can't write on {0!r}, do you have required privileges?".format(args.file)
+
+        scheme = scheme_class.for_cell(*get_scheme_params(args.interface, 'adhoc', args.scheme))
+    else:
+        scheme = scheme_class.find(args.interface, args.scheme)
+        assert scheme, "Couldn't find a scheme named {0!r}, did you mean to use -a?".format(args.scheme)
+
+    try:
+        scheme.activate()
+    except ConnectionError:
+        assert False, "Failed to connect to %s." % scheme.name
+
+
+def autoconnect_command(args):
+    ssids = [cell.ssid for cell in Cell.all(args.interface)]
+
+    for scheme in Scheme.all():
+        # TODO: make it easier to get the SSID off of a scheme.
+        ssid = scheme.options.get('wpa-ssid', scheme.options.get('wireless-essid'))
+        if ssid in ssids:
+            sys.stderr.write('Connecting to "%s".\n' % ssid)
+            try:
+                scheme.activate()
+            except ConnectionError:
+                assert False, "Failed to connect to %s." % scheme.name
+            break
+    else:
+        assert False, "Couldn't find any schemes that are currently available."
+
+
+def arg_parser():
+    parser = argparse.ArgumentParser()
+    parser.add_argument('-i',
+                        '--interface',
+                        default='wlan0',
+                        help="Specifies which interface to use (wlan0, eth0, etc.)")
+    parser.add_argument('-f',
+                        '--file',
+                        default='/etc/network/interfaces',
+                        help="Specifies which file for scheme storage.")
+    
+    subparsers = parser.add_subparsers(title='commands')
+    
+    parser_scan = subparsers.add_parser('scan', help="Shows a list of available networks.")
+    parser_scan.set_defaults(func=scan_command)
+    
+    parser_list = subparsers.add_parser('list', help="Shows a list of networks already configured.")
+    parser_list.set_defaults(func=list_command)
+    
+    scheme_help = ("A memorable nickname for a wireless network."
+                   "  If SSID is not provided, the network will be guessed using SCHEME.")
+    ssid_help = ("The SSID for the network to which you wish to connect."
+                 "  This is fuzzy matched, so you don't have to be precise.")
+    
+    parser_show = subparsers.add_parser('config',
+                                        help="Prints the configuration to connect to a new network.")
+    parser_show.add_argument('scheme', help=scheme_help, metavar='SCHEME')
+    parser_show.add_argument('ssid', nargs='?', help=ssid_help, metavar='SSID')
+    parser_show.set_defaults(func=show_command)
+    
+    parser_add = subparsers.add_parser('add',
+                                       help="Adds the configuration to connect to a new network.")
+    parser_add.add_argument('scheme', help=scheme_help, metavar='SCHEME')
+    parser_add.add_argument('ssid', nargs='?', help=ssid_help, metavar='SSID')
+    parser_add.set_defaults(func=add_command)
+    
+    parser_connect = subparsers.add_parser('connect',
+                                           help="Connects to the network corresponding to SCHEME")
+    parser_connect.add_argument('scheme',
+                                help="The nickname of the network to which you wish to connect.",
+                                metavar='SCHEME')
+    parser_connect.add_argument('-a',
+                                '--ad-hoc',
+                                dest='adhoc',
+                                action="store_true",
+                                help="Connect to a network without storing it in the config file")
+    parser_connect.set_defaults(func=connect_command)
+    
+    
+    # TODO: how to specify the correct interfaces file to work off of.
+    parser_connect.get_options = lambda: [scheme.name for scheme in Scheme.all()]
+
+    parser_autoconnect = subparsers.add_parser(
+        'autoconnect',
+        help="Searches for saved schemes that are currently"
+             " available and connects to the first one it finds."
+    )
+    parser_autoconnect.set_defaults(func=autoconnect_command)
+
+    return parser, subparsers
+
+
+def autocomplete(position, wordlist, subparsers):
+    if position == 1:
+        ret = subparsers.choices.keys()
+    else:
+        try:
+            prev = wordlist[position - 1]
+            ret = subparsers.choices[prev].get_options()
+        except (IndexError, KeyError, AttributeError):
+            ret = []
+
+    print(' '.join(ret))
+
+
+if __name__ == "__main__":
+    parser, subparsers = arg_parser()
+
+    if len(sys.argv) == 1:
+        argv = ['scan']
+    else:
+        argv = sys.argv[1:]
+
+    args = parser.parse_args(argv)
+
+    try:
+        if 'WIFI_AUTOCOMPLETE' in os.environ:
+            autocomplete(int(os.environ['COMP_CWORD']),
+                         os.environ['COMP_WORDS'].split(), subparsers)
+        else:
+            args.func(args)
+    except (AssertionError, InterfaceError) as e:
+        sys.stderr.write("Error: ")
+        sys.exit(e)
diff --git a/extras/wifi-completion.bash b/extras/wifi-completion.bash
new file mode 100644
index 0000000..4b1988d
--- /dev/null
+++ b/extras/wifi-completion.bash
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+_wifi()
+{
+  local cur opts
+  COMPREPLY=()
+  cur="${COMP_WORDS[COMP_CWORD]}"
+
+  opts=$( COMP_CWORD=$COMP_CWORD \
+          COMP_WORDS="${COMP_WORDS[*]}" \
+          WIFI_AUTOCOMPLETE=1 \
+          $1 )
+
+  COMPREPLY=($(compgen -W "$opts" -- ${cur}))
+
+  return 0
+}
+
+complete -F _wifi wifi
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..861a9f5
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,5 @@
+[egg_info]
+tag_build = 
+tag_date = 0
+tag_svn_revision = 0
+
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..9add77d
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+from setuptools import setup
+import os
+
+__doc__ = """
+Command line tool and library wrappers around iwlist and
+/etc/network/interfaces.
+"""
+
+
+def read(fname):
+    return open(os.path.join(os.path.dirname(__file__), fname)).read()
+
+
+install_requires = [
+    'setuptools',
+    'pbkdf2',
+]
+try:
+    import argparse
+except:
+    install_requires.append('argparse')
+
+version = '0.3.8'
+
+data_files = [
+    ('/etc/bash_completion.d/', ['extras/wifi-completion.bash']),
+]
+for entry in data_files:
+    # make sure we actually have write access to the target folder and if not don't
+    # include it in data_files
+    if not os.access(entry[0], os.W_OK):
+        print("Skipping copying files to %s, no write access" % entry[0])
+        data_files.remove(entry)
+
+setup(
+    name='wifi',
+    version=version,
+    author='Rocky Meza, Gavin Wahl',
+    author_email='rockymeza at gmail.com',
+    description=__doc__,
+    long_description='\n\n'.join([read('README.rst'), read('CHANGES.rst')]),
+    packages=['wifi'],
+    scripts=['bin/wifi'],
+    test_suite='tests',
+    platforms=["Debian"],
+    license='BSD',
+    install_requires=install_requires,
+    classifiers=[
+        "License :: OSI Approved :: BSD License",
+        "Topic :: System :: Networking",
+        "Operating System :: POSIX :: Linux",
+        "Environment :: Console",
+        "Programming Language :: Python",
+        "Programming Language :: Python :: 2.6",
+        "Programming Language :: Python :: 2.7",
+        "Programming Language :: Python :: 3.3",
+    ],
+    data_files=data_files
+)
diff --git a/wifi.egg-info/PKG-INFO b/wifi.egg-info/PKG-INFO
new file mode 100644
index 0000000..b578bd1
--- /dev/null
+++ b/wifi.egg-info/PKG-INFO
@@ -0,0 +1,140 @@
+Metadata-Version: 1.1
+Name: wifi
+Version: 0.3.8
+Summary: 
+Command line tool and library wrappers around iwlist and
+/etc/network/interfaces.
+
+Home-page: UNKNOWN
+Author: Rocky Meza, Gavin Wahl
+Author-email: rockymeza at gmail.com
+License: BSD
+Description: wifi
+        ----
+        
+        Wifi provides a command line wrapper for iwlist and /etc/network/interfaces
+        that makes it easier to connect the WiFi networks from the command line.  The
+        wifi command is also implemented as a library that can be used from Python.
+        
+        ::
+        
+            # pip install wifi
+            # wifi --help
+        
+        
+        .. image:: https://travis-ci.org/rockymeza/wifi.png?branch=master
+           :target: https://travis-ci.org/rockymeza/wifi
+        
+        The documentation for wifi lives at https://wifi.readthedocs.org/en/latest/.
+        
+        
+        Changelog
+        =========
+        
+        0.3.8
+        ^^^^^
+        :release-date: 2016-03-11
+        
+        - Parse noise level if available (#91 - thanks zgoda-mobica)
+        
+        0.3.7
+        ^^^^^
+        :release-date: 2016-03-11
+        
+        - Fix bugs related to scheme parsing (#59, #42)
+        
+        0.3.6
+        ^^^^^
+        :release-date: 2016-02-11
+        
+        - Set all attributes to None in Cell.__init__ (#88 - thanks stvad)
+        
+        0.3.5
+        ^^^^^
+        :release-date: 2016-01-24
+        
+        - Better password handling (#62 - thanks foosel)
+        - Account for Cells with no SSID (#86 - thanks tlau)
+        
+        0.3.4
+        ^^^^^
+        :release-date: 2014-09-02
+        
+        - Fixed installation missing some files (#48 - thanks luckydonald)
+        
+        0.3.3
+        ^^^^^
+        :release-date: 2014-08-31
+        
+        - Check for write access for bashcompletion via os.access (#41, #47 - thanks foosel and jegger)
+        - Fixed scanning when quality is reported absolutely (#45 - jeromelebel)
+        - Fixed channel parsing (#33, #39 - thanks gavinwahl and qizha)
+        
+        0.3.2
+        ^^^^^
+        :release-date: 2014-07-26
+        
+        - Only run if __name__ == '__main__' (#29 - thanks Jonwei)
+        - Try to connect to the nearest Access Point
+        - wifi scan was failing when Bit Rate was the last line of output (#42 - thanks jargij)
+        - Added documentation for signal and quality on Cell
+        
+        0.3.1
+        ^^^^^
+        :release-date: 2014-02-10
+        
+        - Scheme.activate was failing on a TypeError in Python3
+        
+        0.3.0
+        ^^^^^
+        :release-date: 2014-02-09
+        
+        - Scheme.activate now throws a ConnectionError if activation failed (#17 - thanks alexykot)
+        - Cell.all now throws an InterfaceError if scanning failed (#18 - thanks alexykot)
+        - Better error message when scheme isn't found (#19 - thanks gavinwahl)
+        - Added ability to delete schemes (#20 - thanks spektom)
+        - Added the --file option (#21)
+        - Scheme.activate returns a Connection object (#22)
+        - Added the autoconnect command (#23)
+        - Fixed parsing error missing channel (#24 - thanks LiorKirsch)
+        - Fixed relative signal return as zero (#25 - thanks LiorKirsch)
+        - Relative signals are now converted to dBm (#26 - thanks LiorKirsch)
+        - Various codebase cleanup (#27 - thanks ramnes)
+        - Added support for WPA Version 1 (#28 - thanks LiorKirsch)
+        - Fixed Python3 support for WPA/PBKDF2
+        
+        0.2.2
+        ^^^^^
+        :release-date: 2013-12-25
+        
+        - Fixed relative signal parsing bug (#12 - thanks alexykot)
+        
+        0.2.1
+        ^^^^^
+        :release-date: 2013-11-22
+        
+        - Fixed print_table str/int bug (#13 - thanks DanLipsitt)
+        
+        0.2.0
+        ^^^^^
+        :release-date: 2013-09-27
+        
+        - Added support for WEP
+        - Fixed bug related to very short SSIDs
+        - Fixed bug related to numeric passkeys
+        
+        0.1.1
+        ^^^^^
+        :release-date: 2013-05-26
+        
+        - Updated setup.py to actually install the bash completion script
+        
+Platform: Debian
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Topic :: System :: Networking
+Classifier: Operating System :: POSIX :: Linux
+Classifier: Environment :: Console
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3.3
diff --git a/wifi.egg-info/SOURCES.txt b/wifi.egg-info/SOURCES.txt
new file mode 100644
index 0000000..98c1e86
--- /dev/null
+++ b/wifi.egg-info/SOURCES.txt
@@ -0,0 +1,19 @@
+CHANGES.rst
+CONTRIBUTING.rst
+LICENSE
+MANIFEST.in
+README.rst
+setup.py
+bin/wifi
+extras/wifi-completion.bash
+wifi/__init__.py
+wifi/exceptions.py
+wifi/scan.py
+wifi/scheme.py
+wifi/subprocess_compat.py
+wifi/utils.py
+wifi.egg-info/PKG-INFO
+wifi.egg-info/SOURCES.txt
+wifi.egg-info/dependency_links.txt
+wifi.egg-info/requires.txt
+wifi.egg-info/top_level.txt
\ No newline at end of file
diff --git a/wifi.egg-info/dependency_links.txt b/wifi.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/wifi.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/wifi.egg-info/requires.txt b/wifi.egg-info/requires.txt
new file mode 100644
index 0000000..2b2fe60
--- /dev/null
+++ b/wifi.egg-info/requires.txt
@@ -0,0 +1,2 @@
+setuptools
+pbkdf2
diff --git a/wifi.egg-info/top_level.txt b/wifi.egg-info/top_level.txt
new file mode 100644
index 0000000..e1b6c79
--- /dev/null
+++ b/wifi.egg-info/top_level.txt
@@ -0,0 +1 @@
+wifi
diff --git a/wifi/__init__.py b/wifi/__init__.py
new file mode 100644
index 0000000..777f763
--- /dev/null
+++ b/wifi/__init__.py
@@ -0,0 +1,2 @@
+from wifi.scan import Cell
+from wifi.scheme import Scheme
diff --git a/wifi/exceptions.py b/wifi/exceptions.py
new file mode 100644
index 0000000..3a75b37
--- /dev/null
+++ b/wifi/exceptions.py
@@ -0,0 +1,6 @@
+class ConnectionError(Exception):
+    pass
+
+
+class InterfaceError(Exception):
+    pass
diff --git a/wifi/scan.py b/wifi/scan.py
new file mode 100644
index 0000000..29f61ad
--- /dev/null
+++ b/wifi/scan.py
@@ -0,0 +1,171 @@
+from __future__ import division
+
+import re
+import textwrap
+
+import wifi.subprocess_compat as subprocess
+from wifi.utils import db2dbm
+from wifi.exceptions import InterfaceError
+
+
+class Cell(object):
+    """
+    Presents a Python interface to the output of iwlist.
+    """
+
+    def __init__(self):
+        self.ssid = None
+        self.bitrates = []
+        self.address = None
+        self.channel = None
+        self.encrypted = False
+        self.encryption_type = None
+        self.frequency = None
+        self.mode = None
+        self.quality = None
+        self.signal = None
+        self.noise = None
+
+    def __repr__(self):
+        return 'Cell(ssid={ssid})'.format(**vars(self))
+
+    @classmethod
+    def all(cls, interface):
+        """
+        Returns a list of all cells extracted from the output of iwlist.
+        """
+        try:
+            iwlist_scan = subprocess.check_output(['/sbin/iwlist', interface, 'scan'],
+                                                  stderr=subprocess.STDOUT)
+        except subprocess.CalledProcessError as e:
+            raise InterfaceError(e.output.strip())
+        else:
+            iwlist_scan = iwlist_scan.decode('utf-8')
+        cells = map(Cell.from_string, cells_re.split(iwlist_scan)[1:])
+
+        return cells
+
+    @classmethod
+    def from_string(cls, cell_string):
+        """
+        Parses the output of iwlist scan for one cell and returns a Cell
+        object for it.
+        """
+        return normalize(cell_string)
+
+    @classmethod
+    def where(cls, interface, fn):
+        """
+        Runs a filter over the output of :meth:`all` and the returns
+        a list of cells that match that filter.
+        """
+        return list(filter(fn, cls.all(interface)))
+
+
+cells_re = re.compile(r'Cell \d+ - ')
+quality_re_dict = {'dBm': re.compile(r'Quality[=:](?P<quality>\d+/\d+).*Signal level[=:](?P<siglevel>-\d+) dBm?(.*Noise level[=:](?P<noiselevel>-\d+) dBm)?'),
+                   'relative': re.compile(r'Quality[=:](?P<quality>\d+/\d+).*Signal level[=:](?P<siglevel>\d+/\d+)'),
+                   'absolute': re.compile(r'Quality[=:](?P<quality>\d+).*Signal level[=:](?P<siglevel>\d+)')}
+frequency_re = re.compile(r'^(?P<frequency>[\d\.]+ .Hz)(?:[\s\(]+Channel\s+(?P<channel>\d+)[\s\)]+)?$')
+
+
+identity = lambda x: x
... 457 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/wifi-python.git



More information about the Python-modules-commits mailing list