├── docs ├── source │ ├── _static │ │ └── .gitkeep │ ├── changes.rst │ ├── modules.rst │ ├── index.rst │ └── conf.py └── Makefile ├── wifi_survey_heatmap ├── vendor │ ├── __init__.py │ └── iwlib │ │ ├── __init__.py │ │ ├── AUTHORS │ │ ├── utils.py │ │ ├── iwlist.py │ │ ├── iwconfig.py │ │ ├── _iwlib_build.py │ │ └── COPYING ├── __init__.py ├── tests │ ├── __init__.py │ └── test_version.py ├── version.py ├── scancli.py ├── collector.py ├── ui.py └── heatmap.py ├── setup.cfg ├── MANIFEST.in ├── pytest.ini ├── CHANGES.rst ├── examples ├── rssi_WAP1.png ├── jitter_WAP1.png ├── quality_WAP1.png ├── udp_Mbps_WAP1.png ├── channels24_WAP1.png ├── channels5_WAP1.png ├── example_floorplan.png ├── example_with_marks.png ├── tcp_upload_Mbps_WAP1.png └── tcp_download_Mbps_WAP1.png ├── .github ├── CONTRIBUTING.md ├── PULL_REQUEST_TEMPLATE.md └── ISSUE_TEMPLATE.md ├── .coveragerc ├── .travis.yml ├── .gitignore ├── tox.ini ├── setup.py ├── README.rst └── LICENSE /docs/source/_static/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /wifi_survey_heatmap/vendor/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal=1 3 | -------------------------------------------------------------------------------- /docs/source/changes.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../../CHANGES.rst 2 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include CHANGES.rst 2 | include LICENSE 3 | include README.rst 4 | -------------------------------------------------------------------------------- /pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | pep8ignore = 3 | lib/* ALL 4 | lib64/* ALL 5 | pep8maxlinelength = 80 6 | 7 | -------------------------------------------------------------------------------- /CHANGES.rst: -------------------------------------------------------------------------------- 1 | Changelog 2 | ========= 3 | 4 | 0.1.0 (YYYY-MM-DD) 5 | ------------------ 6 | 7 | * Initial release 8 | -------------------------------------------------------------------------------- /wifi_survey_heatmap/vendor/iwlib/__init__.py: -------------------------------------------------------------------------------- 1 | # for backwards compatibility 2 | from .iwconfig import get_iwconfig 3 | -------------------------------------------------------------------------------- /examples/rssi_WAP1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramonfontes/python-wifi-survey-heatmap/master/examples/rssi_WAP1.png -------------------------------------------------------------------------------- /examples/jitter_WAP1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramonfontes/python-wifi-survey-heatmap/master/examples/jitter_WAP1.png -------------------------------------------------------------------------------- /examples/quality_WAP1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramonfontes/python-wifi-survey-heatmap/master/examples/quality_WAP1.png -------------------------------------------------------------------------------- /examples/udp_Mbps_WAP1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramonfontes/python-wifi-survey-heatmap/master/examples/udp_Mbps_WAP1.png -------------------------------------------------------------------------------- /examples/channels24_WAP1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramonfontes/python-wifi-survey-heatmap/master/examples/channels24_WAP1.png -------------------------------------------------------------------------------- /examples/channels5_WAP1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramonfontes/python-wifi-survey-heatmap/master/examples/channels5_WAP1.png -------------------------------------------------------------------------------- /examples/example_floorplan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramonfontes/python-wifi-survey-heatmap/master/examples/example_floorplan.png -------------------------------------------------------------------------------- /examples/example_with_marks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramonfontes/python-wifi-survey-heatmap/master/examples/example_with_marks.png -------------------------------------------------------------------------------- /docs/source/modules.rst: -------------------------------------------------------------------------------- 1 | wifi-survey-heatmap 2 | =============== 3 | 4 | .. toctree:: 5 | :maxdepth: 4 6 | 7 | wifi_survey_heatmap 8 | -------------------------------------------------------------------------------- /examples/tcp_upload_Mbps_WAP1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramonfontes/python-wifi-survey-heatmap/master/examples/tcp_upload_Mbps_WAP1.png -------------------------------------------------------------------------------- /examples/tcp_download_Mbps_WAP1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramonfontes/python-wifi-survey-heatmap/master/examples/tcp_download_Mbps_WAP1.png -------------------------------------------------------------------------------- /wifi_survey_heatmap/vendor/iwlib/AUTHORS: -------------------------------------------------------------------------------- 1 | Jiri Popelka 2009-07-24 - 2012-03-21 2 | Nathan Hoad 2013-03-21 - present 3 | Nathan Typanski 2014-10-01 (Python 3 support) 4 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing to wifi-survey-heatmap 2 | =============================== 3 | 4 | See the [Documentation on ReadTheDocs](http://wifi-survey-heatmap.readthedocs.org/en/master/index.html) for information on how to contribute. 5 | -------------------------------------------------------------------------------- /docs/source/index.rst: -------------------------------------------------------------------------------- 1 | .. meta:: 2 | :description: Description of wifi-survey-heatmap goes here. 3 | 4 | .. include:: ../../README.rst 5 | 6 | Contents 7 | ========= 8 | 9 | .. toctree:: 10 | :maxdepth: 4 11 | 12 | API 13 | Changelog 14 | 15 | Indices and tables 16 | ================== 17 | 18 | * :ref:`genindex` 19 | * :ref:`modindex` 20 | * :ref:`search` 21 | -------------------------------------------------------------------------------- /.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | branch = True 3 | omit = lib/* 4 | wifi-survey-heatmap/tests/* 5 | setup.py 6 | 7 | [report] 8 | exclude_lines = 9 | # this cant ever be run by py.test, but it just calls one function, 10 | # so ignore it 11 | if __name__ == .__main__.: 12 | if sys.version_info.+ 13 | raise NotImplementedError 14 | except ImportError: 15 | .*# nocoverage.* 16 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | sudo: false 3 | 4 | cache: pip 5 | 6 | matrix: 7 | include: 8 | - python: "2.7" 9 | env: TOXENV=py27 10 | - python: "3.4" 11 | env: TOXENV=py34 12 | - python: "3.5" 13 | env: TOXENV=py35 14 | - python: "3.6" 15 | env: TOXENV=py36 16 | - python: "3.7" 17 | env: TOXENV=py37 18 | - python: "3.6" 19 | env: TOXENV=docs 20 | 21 | install: 22 | - virtualenv --version 23 | - git config --global user.email "travisci@jasonantman.com" 24 | - git config --global user.name "travisci" 25 | - pip install tox 26 | - pip install codecov 27 | - pip freeze 28 | - virtualenv --version 29 | script: 30 | - tox -r 31 | 32 | after_success: 33 | - codecov 34 | 35 | notifications: 36 | email: 37 | on_failure: always 38 | branches: 39 | except: 40 | - "/^noci-.*$/" 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | bin/ 12 | include/ 13 | env/ 14 | build/ 15 | develop-eggs/ 16 | dist/ 17 | downloads/ 18 | eggs/ 19 | .eggs/ 20 | lib/ 21 | lib64/ 22 | parts/ 23 | sdist/ 24 | var/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | pip-selfcheck.json 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *,cover 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | 57 | # Sphinx documentation 58 | docs/build/ 59 | 60 | # PyBuilder 61 | target/ 62 | 63 | # virtualenv 64 | bin/ 65 | include/ 66 | 67 | .idea/ 68 | result.json 69 | *.json 70 | /jitter_*.png 71 | /quality_*.png 72 | /rssi_*.png 73 | /tcp_*.png 74 | /udp_*.png 75 | /channels*.png 76 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py27,py34,py35,py36,py37,docs 3 | 4 | [testenv] 5 | deps = 6 | cov-core 7 | coverage 8 | execnet 9 | pep8 10 | py 11 | pytest>=2.8.3 12 | pytest-cache 13 | pytest-cov 14 | pytest-pep8 15 | pytest-flakes 16 | mock 17 | 18 | passenv=TRAVIS* 19 | setenv = 20 | TOXINIDIR={toxinidir} 21 | TOXDISTDIR={distdir} 22 | sitepackages = False 23 | whitelist_externals = env test 24 | 25 | commands = 26 | python --version 27 | virtualenv --version 28 | pip --version 29 | pip freeze 30 | py.test -rxs -vv --durations=10 --pep8 --flakes --blockage --cov-report term-missing --cov-report xml --cov-report html --cov-config {toxinidir}/.coveragerc --cov=wifi_survey_heatmap {posargs} wifi_survey_heatmap 31 | 32 | # always recreate the venv 33 | recreate = True 34 | 35 | [testenv:docs] 36 | # this really just makes sure README.rst will parse on pypi 37 | passenv = TRAVIS* CONTINUOUS_INTEGRATION AWS* READTHEDOCS* 38 | setenv = 39 | TOXINIDIR={toxinidir} 40 | TOXDISTDIR={distdir} 41 | CI=true 42 | deps = 43 | docutils 44 | pygments 45 | sphinx 46 | sphinx_rtd_theme 47 | basepython = python3.6 48 | commands = 49 | python --version 50 | virtualenv --version 51 | pip --version 52 | pip freeze 53 | rst2html.py --halt=2 README.rst /dev/null 54 | sphinx-apidoc wifi_survey_heatmap wifi_survey_heatmap/tests -o {toxinidir}/docs/source -e -f -M 55 | # link check 56 | # -n runs in nit-picky mode 57 | # -W turns warnings into errors 58 | sphinx-build -a -n -W -b linkcheck {toxinidir}/docs/source {toxinidir}/docs/build/html 59 | # build 60 | sphinx-build -a -n -W -b html {toxinidir}/docs/source {toxinidir}/docs/build/html 61 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | __IMPORTANT:__ Please take note of the below checklist, especially the first two items. 2 | 3 | # Pull Request Checklist 4 | 5 | - [ ] All pull requests must include the Contributor License Agreement (see below). 6 | - [ ] Code should conform to the following: 7 | - [ ] pep8 compliant with some exceptions (see pytest.ini) 8 | - [ ] 100% test coverage with pytest (with valid tests). If you have difficulty 9 | writing tests for the code, feel free to ask for help or submit the PR without tests. 10 | - [ ] Complete, correctly-formatted documentation for all classes, functions and methods. 11 | - [ ] documentation has been rebuilt with ``tox -e docs`` 12 | - [ ] All modules should have (and use) module-level loggers. 13 | - [ ] **Commit messages** should be meaningful, and reference the Issue number 14 | if you're working on a GitHub issue (i.e. "issue #x - "). Please 15 | refrain from using the "fixes #x" notation unless you are *sure* that the 16 | the issue is fixed in that commit. 17 | - [ ] Git history is fully intact; please do not squash or rewrite history. 18 | 19 | ## Contributor License Agreement 20 | 21 | By submitting this work for inclusion in wifi-survey-heatmap, I agree to the following terms: 22 | 23 | * The contribution included in this request (and any subsequent revisions or versions of it) 24 | is being made under the same license as the wifi-survey-heatmap project (the Affero GPL v3, 25 | or any subsequent version of that license if adopted by wifi-survey-heatmap). 26 | * My contribution may perpetually be included in and distributed with wifi-survey-heatmap; submitting 27 | this pull request grants a perpetual, global, unlimited license for it to be used and distributed 28 | under the terms of wifi-survey-heatmap's license. 29 | * I have the legal power and rights to agree to these terms. 30 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Please remove all of this template but the relevant section below, and fill in 2 | each item in that section. 3 | 4 | ## Feature Request 5 | 6 | ### Feature Description 7 | 8 | Describe in detail the feature you would like to see implemented, especially 9 | how it would work from a user perspective and what benefits it adds. Your description 10 | should be detailed enough to be used to determine if code written for the feature 11 | adequately solves the problem. 12 | 13 | ### Use Cases 14 | 15 | Describe one or more use cases for why this feature will be useful. 16 | 17 | ### Testing Assistance 18 | 19 | Indicate whether or not you will be able to assist in testing pre-release 20 | code for the feature. 21 | 22 | ## Bug Report 23 | 24 | When reporting a bug, please provide all of the following information, 25 | as well as any additional details that may be useful in reproducing or fixing 26 | the issue: 27 | 28 | ### Version 29 | 30 | wifi-survey-heatmap version, as reported by ``wifi-survey-heatmap --version`` 31 | 32 | ### Installation Method 33 | 34 | How was wifi-survey-heatmap installed (provide as much detail as possible, ideally 35 | the exact command used and whether it was installed in a virtualenv or not). 36 | 37 | ### Supporting Software Versions 38 | 39 | The output of ``python --version`` and ``virtualenv --version`` in the environment 40 | that wifi-survey-heatmap is running in, as well as your operating system type and version. 41 | 42 | ### Actual Output 43 | 44 | ``` 45 | Paste here the output of wifi-survey-heatmap (including the command used to run it), 46 | run with the -vv (debug-level output) flag, that shows the issue. 47 | ``` 48 | 49 | ### Expected Output 50 | 51 | Describe the output that you expected (what's wrong). If possible, after your description, 52 | copy the actual output above and modify it to what was expected. 53 | 54 | ### Testing Assistance 55 | 56 | Indicate whether or not you will be able to assist in testing pre-release 57 | code for the feature. 58 | -------------------------------------------------------------------------------- /wifi_survey_heatmap/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | The latest version of this package is available at: 3 | 4 | 5 | ################################################################################## 6 | Copyright 2018 Jason Antman 7 | 8 | This file is part of wifi-survey-heatmap, also known as wifi-survey-heatmap. 9 | 10 | wifi-survey-heatmap is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU Affero General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | wifi-survey-heatmap is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU Affero General Public License for more details. 19 | 20 | You should have received a copy of the GNU Affero General Public License 21 | along with wifi-survey-heatmap. If not, see . 22 | 23 | The Copyright and Authors attributions contained herein may not be removed or 24 | otherwise altered, except to add the Author attribution of a contributor to 25 | this work. (Additional Terms pursuant to Section 7b of the AGPL v3) 26 | ################################################################################## 27 | While not legally required, I sincerely request that anyone who finds 28 | bugs please submit them at or 29 | to me via email, and that you send any contributions or improvements 30 | either as a pull request on GitHub, or to me via email. 31 | ################################################################################## 32 | 33 | AUTHORS: 34 | Jason Antman 35 | ################################################################################## 36 | """ 37 | -------------------------------------------------------------------------------- /wifi_survey_heatmap/tests/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | The latest version of this package is available at: 3 | 4 | 5 | ################################################################################## 6 | Copyright 2018 Jason Antman 7 | 8 | This file is part of wifi-survey-heatmap, also known as wifi-survey-heatmap. 9 | 10 | wifi-survey-heatmap is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU Affero General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | wifi-survey-heatmap is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU Affero General Public License for more details. 19 | 20 | You should have received a copy of the GNU Affero General Public License 21 | along with wifi-survey-heatmap. If not, see . 22 | 23 | The Copyright and Authors attributions contained herein may not be removed or 24 | otherwise altered, except to add the Author attribution of a contributor to 25 | this work. (Additional Terms pursuant to Section 7b of the AGPL v3) 26 | ################################################################################## 27 | While not legally required, I sincerely request that anyone who finds 28 | bugs please submit them at or 29 | to me via email, and that you send any contributions or improvements 30 | either as a pull request on GitHub, or to me via email. 31 | ################################################################################## 32 | 33 | AUTHORS: 34 | Jason Antman 35 | ################################################################################## 36 | """ 37 | -------------------------------------------------------------------------------- /wifi_survey_heatmap/version.py: -------------------------------------------------------------------------------- 1 | """ 2 | The latest version of this package is available at: 3 | 4 | 5 | ################################################################################## 6 | Copyright 2018 Jason Antman 7 | 8 | This file is part of wifi-survey-heatmap, also known as wifi-survey-heatmap. 9 | 10 | wifi-survey-heatmap is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU Affero General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | wifi-survey-heatmap is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU Affero General Public License for more details. 19 | 20 | You should have received a copy of the GNU Affero General Public License 21 | along with wifi-survey-heatmap. If not, see . 22 | 23 | The Copyright and Authors attributions contained herein may not be removed or 24 | otherwise altered, except to add the Author attribution of a contributor to 25 | this work. (Additional Terms pursuant to Section 7b of the AGPL v3) 26 | ################################################################################## 27 | While not legally required, I sincerely request that anyone who finds 28 | bugs please submit them at or 29 | to me via email, and that you send any contributions or improvements 30 | either as a pull request on GitHub, or to me via email. 31 | ################################################################################## 32 | 33 | AUTHORS: 34 | Jason Antman 35 | ################################################################################## 36 | """ 37 | 38 | VERSION = '0.1.0' 39 | PROJECT_URL = 'https://github.com/jantman/wifi-survey-heatmap' 40 | -------------------------------------------------------------------------------- /wifi_survey_heatmap/vendor/iwlib/utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2009-2012 Red Hat, Inc. 2 | # Copyright (C) 2013-2014 Nathan Hoad. 3 | # 4 | # Interface with iwlib by Nathan Hoad . 5 | # 6 | # This application is free software; you can redistribute it and/or modify it 7 | # under the terms of the GNU General Public License as published by the Free 8 | # Software Foundation; version 2. 9 | # 10 | # This application is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | # General Public License for more details. 14 | 15 | import contextlib 16 | import errno 17 | import os 18 | 19 | from ._iwlib import ffi, lib as iwlib 20 | 21 | 22 | @contextlib.contextmanager 23 | def iwlib_socket(sock=None): 24 | if sock is None: 25 | closing = True 26 | sock = iwlib.iw_sockets_open() 27 | else: 28 | closing = False 29 | 30 | if sock < 0: 31 | raise OSError(ffi.errno, os.strerror(ffi.errno)) 32 | 33 | try: 34 | yield sock 35 | finally: 36 | if closing: 37 | iwlib.iw_sockets_close(sock) 38 | 39 | 40 | def get_max_quality(interface): 41 | """ 42 | Return max quality of an interface. Useful for working out percentages of 43 | quality results from `iwconfig.scan()`. 44 | """ 45 | range = _get_range_info(interface) 46 | return range.max_qual.qual 47 | 48 | 49 | def supports_scanning(interface): 50 | """ 51 | Check if an interface supports scanning. 52 | Returns true if the device supports scanning. False otherwise. 53 | """ 54 | try: 55 | _get_range_info(interface) 56 | except OSError: 57 | return False 58 | else: 59 | return True 60 | 61 | 62 | def _get_range_info(interface, sock=None): 63 | interface = _get_bytes(interface) 64 | range = ffi.new('struct iw_range *') 65 | 66 | with iwlib_socket(sock=sock) as sock: 67 | has_range = iwlib.iw_get_range_info(sock, interface, range) >= 0 68 | 69 | if not has_range or range.we_version_compiled < 14: 70 | err = errno.ENOTSUP 71 | raise OSError(err, os.strerror(err)) 72 | return range 73 | 74 | 75 | def _parse_stats(stats): 76 | return { 77 | 'quality': stats.qual.qual, 78 | 'level': stats.qual.level, 79 | 'noise': stats.qual.noise, 80 | 'updated': stats.qual.updated, 81 | } 82 | 83 | 84 | def _get_bytes(s): 85 | if isinstance(s, bytes): 86 | return s 87 | return s.encode('utf8') 88 | -------------------------------------------------------------------------------- /wifi_survey_heatmap/vendor/iwlib/iwlist.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2009-2012 Red Hat, Inc. 2 | # Copyright (C) 2013-2014 Nathan Hoad. 3 | # 4 | # Interface with iwlib by Nathan Hoad . 5 | # 6 | # This application is free software; you can redistribute it and/or modify it 7 | # under the terms of the GNU General Public License as published by the Free 8 | # Software Foundation; version 2. 9 | # 10 | # This application is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | # General Public License for more details. 14 | 15 | import os 16 | 17 | from .utils import _get_range_info, _parse_stats, _get_bytes, iwlib_socket 18 | from ._iwlib import ffi, lib as iwlib 19 | 20 | 21 | def scan(interface): 22 | """Perform a scan for access points in the area. 23 | 24 | Arguments: 25 | interface - device to use for scanning (e.g. eth1, wlan0). 26 | """ 27 | interface = _get_bytes(interface) 28 | 29 | head = ffi.new('wireless_scan_head *') 30 | 31 | with iwlib_socket() as sock: 32 | range = _get_range_info(interface, sock=sock) 33 | 34 | if iwlib.iw_scan(sock, interface, range.we_version_compiled, head) != 0: 35 | errno = ffi.errno 36 | strerror = "Error while scanning: %s" % os.strerror(errno) 37 | raise OSError(errno, strerror) 38 | 39 | results = [] 40 | 41 | scan = head.result 42 | 43 | buf = ffi.new('char []', 1024) 44 | 45 | while scan != ffi.NULL: 46 | parsed_scan = {} 47 | 48 | if scan.b.has_mode: 49 | parsed_scan['Mode'] = ffi.string(iwlib.iw_operation_mode[scan.b.mode]) 50 | 51 | if scan.b.has_freq: 52 | parsed_scan['Frequency'] = scan.b.freq 53 | 54 | if scan.b.essid_on: 55 | parsed_scan['ESSID'] = ffi.string(scan.b.essid) 56 | else: 57 | parsed_scan['ESSID'] = b'Auto' 58 | 59 | if scan.has_ap_addr: 60 | iwlib.iw_ether_ntop( 61 | ffi.cast('struct ether_addr *', scan.ap_addr.sa_data), buf) 62 | if scan.b.has_mode and scan.b.mode == iwlib.IW_MODE_ADHOC: 63 | parsed_scan['Cell'] = ffi.string(buf) 64 | else: 65 | parsed_scan['Access Point'] = ffi.string(buf) 66 | 67 | if scan.has_maxbitrate: 68 | iwlib.iw_print_bitrate(buf, len(buf), scan.maxbitrate.value) 69 | parsed_scan['BitRate'] = ffi.string(buf) 70 | 71 | if scan.has_stats: 72 | parsed_scan['stats'] = _parse_stats(scan.stats) 73 | 74 | results.append(parsed_scan) 75 | scan = scan.next 76 | 77 | return results 78 | -------------------------------------------------------------------------------- /wifi_survey_heatmap/tests/test_version.py: -------------------------------------------------------------------------------- 1 | """ 2 | The latest version of this package is available at: 3 | 4 | 5 | ################################################################################## 6 | Copyright 2018 Jason Antman 7 | 8 | This file is part of wifi-survey-heatmap, also known as wifi-survey-heatmap. 9 | 10 | wifi-survey-heatmap is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU Affero General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | wifi-survey-heatmap is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU Affero General Public License for more details. 19 | 20 | You should have received a copy of the GNU Affero General Public License 21 | along with wifi-survey-heatmap. If not, see . 22 | 23 | The Copyright and Authors attributions contained herein may not be removed or 24 | otherwise altered, except to add the Author attribution of a contributor to 25 | this work. (Additional Terms pursuant to Section 7b of the AGPL v3) 26 | ################################################################################## 27 | While not legally required, I sincerely request that anyone who finds 28 | bugs please submit them at or 29 | to me via email, and that you send any contributions or improvements 30 | either as a pull request on GitHub, or to me via email. 31 | ################################################################################## 32 | 33 | AUTHORS: 34 | Jason Antman 35 | ################################################################################## 36 | """ 37 | 38 | import wifi_survey_heatmap.version as version 39 | 40 | import re 41 | import sys 42 | 43 | 44 | class TestVersion(object): 45 | 46 | def test_project_url(self): 47 | expected = 'https://github.com/jantman/wifi-survey-heatmap' 48 | assert version.PROJECT_URL == expected 49 | 50 | def test_is_semver(self): 51 | # see: 52 | # https://github.com/mojombo/semver.org/issues/59#issuecomment-57884619 53 | semver_ptn = re.compile( 54 | r'^' 55 | r'(?P(?:' 56 | r'0|(?:[1-9]\d*)' 57 | r'))' 58 | r'\.' 59 | r'(?P(?:' 60 | r'0|(?:[1-9]\d*)' 61 | r'))' 62 | r'\.' 63 | r'(?P(?:' 64 | r'0|(?:[1-9]\d*)' 65 | r'))' 66 | r'(?:-(?P' 67 | r'[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*' 68 | r'))?' 69 | r'(?:\+(?P' 70 | r'[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*' 71 | r'))?' 72 | r'$' 73 | ) 74 | assert semver_ptn.match(version.VERSION) is not None 75 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | """ 2 | The latest version of this package is available at: 3 | 4 | 5 | ################################################################################## 6 | Copyright 2017 Jason Antman 7 | 8 | This file is part of wifi-survey-heatmap, also known as wifi-survey-heatmap. 9 | 10 | wifi-survey-heatmap is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU Affero General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | wifi-survey-heatmap is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU Affero General Public License for more details. 19 | 20 | You should have received a copy of the GNU Affero General Public License 21 | along with wifi-survey-heatmap. If not, see . 22 | 23 | The Copyright and Authors attributions contained herein may not be removed or 24 | otherwise altered, except to add the Author attribution of a contributor to 25 | this work. (Additional Terms pursuant to Section 7b of the AGPL v3) 26 | ################################################################################## 27 | While not legally required, I sincerely request that anyone who finds 28 | bugs please submit them at or 29 | to me via email, and that you send any contributions or improvements 30 | either as a pull request on GitHub, or to me via email. 31 | ################################################################################## 32 | 33 | AUTHORS: 34 | Jason Antman 35 | ################################################################################## 36 | """ 37 | 38 | from setuptools import setup, find_packages 39 | from wifi_survey_heatmap.version import VERSION, PROJECT_URL 40 | 41 | with open('README.rst') as file: 42 | long_description = file.read() 43 | 44 | requires = [ 45 | 'cffi>=1.0.0', 46 | 'iperf3==0.1.10', 47 | 'matplotlib==3.0.1', 48 | 'scipy==1.1.0' 49 | ] 50 | 51 | classifiers = [ 52 | 'Development Status :: 1 - Planning', 53 | 'Environment :: X11 Applications :: GTK', 54 | 'Intended Audience :: End Users/Desktop', 55 | 'Intended Audience :: Information Technology', 56 | 'Intended Audience :: System Administrators', 57 | 'License :: OSI Approved :: GNU Affero General Public License ' 58 | 'v3 or later (AGPLv3+)', 59 | 'Natural Language :: English', 60 | 'Operating System :: POSIX :: Linux', 61 | 'Programming Language :: Python', 62 | 'Programming Language :: Python :: 2.7', 63 | 'Programming Language :: Python :: 3', 64 | 'Programming Language :: Python :: 3.4', 65 | 'Programming Language :: Python :: 3.5', 66 | 'Programming Language :: Python :: 3.6', 67 | 'Topic :: System :: Networking' 68 | ] 69 | 70 | setup( 71 | name='wifi-survey-heatmap', 72 | version=VERSION, 73 | author='Jason Antman', 74 | author_email='jason@jasonantman.com', 75 | packages=find_packages(), 76 | url=PROJECT_URL, 77 | description='A Python application for Linux machines to perform WiFi site' 78 | ' surveys and present the results as a heatmap overlayed on ' 79 | 'a floorplan.', 80 | long_description=long_description, 81 | install_requires=requires, 82 | setup_requires=['cffi>=1.0.0'], 83 | keywords="wifi wireless wlan survey map heatmap", 84 | classifiers=classifiers, 85 | entry_points={ 86 | 'console_scripts': [ 87 | 'wifi-scan = wifi_survey_heatmap.scancli:main', 88 | 'wifi-survey = wifi_survey_heatmap.ui:main', 89 | 'wifi-heatmap = wifi_survey_heatmap.heatmap:main' 90 | ] 91 | }, 92 | cffi_modules=[ 93 | 'wifi_survey_heatmap/vendor/iwlib/_iwlib_build.py:ffibuilder' 94 | ], 95 | zip_safe=False 96 | ) 97 | -------------------------------------------------------------------------------- /wifi_survey_heatmap/scancli.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """ 3 | The latest version of this package is available at: 4 | 5 | 6 | ################################################################################## 7 | Copyright 2018 Jason Antman 8 | 9 | This file is part of wifi-survey-heatmap, also known as wifi-survey-heatmap. 10 | 11 | wifi-survey-heatmap is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU Affero General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | wifi-survey-heatmap is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU Affero General Public License for more details. 20 | 21 | You should have received a copy of the GNU Affero General Public License 22 | along with wifi-survey-heatmap. If not, see . 23 | 24 | The Copyright and Authors attributions contained herein may not be removed or 25 | otherwise altered, except to add the Author attribution of a contributor to 26 | this work. (Additional Terms pursuant to Section 7b of the AGPL v3) 27 | ################################################################################## 28 | While not legally required, I sincerely request that anyone who finds 29 | bugs please submit them at or 30 | to me via email, and that you send any contributions or improvements 31 | either as a pull request on GitHub, or to me via email. 32 | ################################################################################## 33 | 34 | AUTHORS: 35 | Jason Antman 36 | ################################################################################## 37 | """ 38 | 39 | import sys 40 | import argparse 41 | import logging 42 | import os 43 | 44 | from wifi_survey_heatmap.collector import Collector 45 | 46 | FORMAT = "[%(asctime)s %(levelname)s] %(message)s" 47 | logging.basicConfig(level=logging.WARNING, format=FORMAT) 48 | logger = logging.getLogger() 49 | 50 | 51 | class CliWrapper(object): 52 | 53 | def run(self, ifname, server): 54 | if os.geteuid() != 0: 55 | raise RuntimeError('ERROR: This script must be run as root/sudo.') 56 | c = Collector(ifname, server) 57 | print(c.run()) 58 | 59 | 60 | def parse_args(argv): 61 | """ 62 | parse arguments/options 63 | 64 | this uses the new argparse module instead of optparse 65 | see: 66 | """ 67 | p = argparse.ArgumentParser(description='wifi scan CLI') 68 | p.add_argument('-v', '--verbose', dest='verbose', action='count', default=0, 69 | help='verbose output. specify twice for debug-level output.') 70 | p.add_argument('INTERFACE', type=str, help='Wireless interface name') 71 | p.add_argument('SERVER', type=str, help='iperf3 server IP or hostname') 72 | args = p.parse_args(argv) 73 | return args 74 | 75 | 76 | def set_log_info(): 77 | """set logger level to INFO""" 78 | set_log_level_format(logging.INFO, 79 | '%(asctime)s %(levelname)s:%(name)s:%(message)s') 80 | 81 | 82 | def set_log_debug(): 83 | """set logger level to DEBUG, and debug-level output format""" 84 | set_log_level_format( 85 | logging.DEBUG, 86 | "%(asctime)s [%(levelname)s %(filename)s:%(lineno)s - " 87 | "%(name)s.%(funcName)s() ] %(message)s" 88 | ) 89 | 90 | 91 | def set_log_level_format(level, format): 92 | """ 93 | Set logger level and format. 94 | 95 | :param level: logging level; see the :py:mod:`logging` constants. 96 | :type level: int 97 | :param format: logging formatter format string 98 | :type format: str 99 | """ 100 | formatter = logging.Formatter(fmt=format) 101 | logger.handlers[0].setFormatter(formatter) 102 | logger.setLevel(level) 103 | 104 | 105 | def main(): 106 | args = parse_args(sys.argv[1:]) 107 | 108 | # set logging level 109 | if args.verbose > 1: 110 | set_log_debug() 111 | elif args.verbose == 1: 112 | set_log_info() 113 | 114 | CliWrapper().run(args.INTERFACE, args.SERVER) 115 | 116 | 117 | if __name__ == "__main__": 118 | main() 119 | -------------------------------------------------------------------------------- /wifi_survey_heatmap/collector.py: -------------------------------------------------------------------------------- 1 | """ 2 | The latest version of this package is available at: 3 | 4 | 5 | ################################################################################## 6 | Copyright 2018 Jason Antman 7 | 8 | This file is part of wifi-survey-heatmap, also known as wifi-survey-heatmap. 9 | 10 | wifi-survey-heatmap is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU Affero General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | wifi-survey-heatmap is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU Affero General Public License for more details. 19 | 20 | You should have received a copy of the GNU Affero General Public License 21 | along with wifi-survey-heatmap. If not, see . 22 | 23 | The Copyright and Authors attributions contained herein may not be removed or 24 | otherwise altered, except to add the Author attribution of a contributor to 25 | this work. (Additional Terms pursuant to Section 7b of the AGPL v3) 26 | ################################################################################## 27 | While not legally required, I sincerely request that anyone who finds 28 | bugs please submit them at or 29 | to me via email, and that you send any contributions or improvements 30 | either as a pull request on GitHub, or to me via email. 31 | ################################################################################## 32 | 33 | AUTHORS: 34 | Jason Antman 35 | ################################################################################## 36 | """ 37 | 38 | import logging 39 | from time import sleep 40 | 41 | from wifi_survey_heatmap.vendor.iwlib.iwconfig import get_iwconfig 42 | from wifi_survey_heatmap.vendor.iwlib.iwlist import scan 43 | 44 | import iperf3 45 | 46 | logger = logging.getLogger(__name__) 47 | 48 | 49 | class Collector(object): 50 | 51 | def __init__(self, interface_name, server_addr): 52 | super().__init__() 53 | logger.debug( 54 | 'Initializing Collector for interface: %s; iperf server: %s', 55 | interface_name, server_addr 56 | ) 57 | self._interface_name = interface_name 58 | self._iperf_server = server_addr 59 | 60 | def run_iperf(self, udp=False, reverse=False): 61 | client = iperf3.Client() 62 | client.server_hostname = self._iperf_server 63 | client.port = 5201 64 | client.protocol = 'udp' if udp else 'tcp' 65 | client.reverse = reverse 66 | logger.debug( 67 | 'Running iperf to %s; udp=%s reverse=%s', self._iperf_server, 68 | udp, reverse 69 | ) 70 | for retry in range(0, 4): 71 | res = client.run() 72 | if res.error is None: 73 | break 74 | logger.error('iperf error: %s; retrying', res.error) 75 | logger.debug('iperf result: %s', res) 76 | return res 77 | 78 | def _run_all_iperf(self): 79 | res = {'tcp': {}, 'udp': {}} 80 | for proto_name, udp in {'tcp': False, 'udp': True}.items(): 81 | for dest_name, reverse in { 82 | 'client_to_server': False, 83 | 'server_to_client': True 84 | }.items(): 85 | tmp = self.run_iperf(udp, reverse) 86 | if 'end' in tmp.json: 87 | tmp = tmp.json['end'] 88 | res[proto_name][dest_name] = tmp 89 | logger.debug('Sleeping 2s before next iperf run') 90 | sleep(2) 91 | return res 92 | 93 | def run_iwconfig(self): 94 | logger.debug('Getting iwconfig...') 95 | res = get_iwconfig(self._interface_name) 96 | logger.debug('iwconfig result: %s', res) 97 | return res 98 | 99 | def run_iwscan(self): 100 | logger.debug('Scanning...') 101 | res = scan(self._interface_name) 102 | logger.debug('scan result: %s', res) 103 | return res 104 | 105 | def run(self): 106 | res = { 107 | 'iperf': self._run_all_iperf() 108 | } 109 | logger.debug('Getting iwconfig...') 110 | res['config'] = get_iwconfig(self._interface_name) 111 | logger.debug('iwconfig result: %s', res['config']) 112 | logger.debug('Scanning...') 113 | res['scan'] = scan(self._interface_name) 114 | logger.debug('scan result: %s', res['scan']) 115 | return res 116 | -------------------------------------------------------------------------------- /wifi_survey_heatmap/vendor/iwlib/iwconfig.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2009-2012 Red Hat, Inc. 2 | # Copyright (C) 2013-2014 Nathan Hoad. 3 | # 4 | # Interface with iwlib by Nathan Hoad . 5 | # 6 | # This application is free software; you can redistribute it and/or modify it 7 | # under the terms of the GNU General Public License as published by the Free 8 | # Software Foundation; version 2. 9 | # 10 | # This application is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | # General Public License for more details. 14 | 15 | import os 16 | import errno 17 | 18 | from .utils import _parse_stats, _get_bytes, iwlib_socket 19 | from ._iwlib import ffi, lib as iwlib 20 | 21 | 22 | def get_iwconfig(interface): 23 | """ 24 | Retrieve the current configuration of a given interface 25 | 26 | Arguments: 27 | interface - device to work on (e.g. eth1, wlan0). 28 | """ 29 | with iwlib_socket() as sock: 30 | return _get_iwconfig(interface, sock) 31 | 32 | 33 | def _get_iwconfig(interface, sock): 34 | interface = _get_bytes(interface) 35 | 36 | wrq = ffi.new('struct iwreq*') 37 | 38 | iwconfig = {} 39 | 40 | def get_ext(flag): 41 | return iwlib.iw_get_ext(sock, interface, flag, wrq) >= 0 42 | 43 | if not get_ext(iwlib.SIOCGIWNAME): 44 | wrq.ifr_ifrn = interface[:iwlib.IFNAMSIZ-1] 45 | wrq.ifr_ifrn[iwlib.IFNAMSIZ-1] = b'\0' 46 | 47 | if iwlib.ioctl(sock, iwlib.SIOCGIFFLAGS, wrq) < 0: 48 | err = errno.ENODEV 49 | else: 50 | err = errno.ENOTSUP 51 | 52 | strerror = os.strerror(err) 53 | 54 | raise OSError(err, "Could not get config for '%s': %s" % (interface.decode('utf8'), strerror)) 55 | 56 | if not get_ext(iwlib.SIOCGIWNWID): 57 | if wrq.u.nwid.disabled: 58 | iwconfig['NWID'] = b"Auto" 59 | else: 60 | iwconfig['NWID'] = ('%x' % (wrq.u.nwid.value)).encode('utf8') 61 | 62 | buf = ffi.new('char []', 1024) 63 | 64 | if get_ext(iwlib.SIOCGIWFREQ): 65 | freq = iwlib.iw_freq2float(ffi.addressof(wrq.u.freq)) 66 | iwlib.iw_print_freq_value(buf, len(buf), freq) 67 | iwconfig['Frequency'] = ffi.string(buf) 68 | 69 | if get_ext(iwlib.SIOCGIWAP): 70 | iwlib.iw_ether_ntop(ffi.cast('struct ether_addr *', wrq.u.ap_addr.sa_data), buf) 71 | mode = wrq.u.mode 72 | has_mode = 0 <= mode < iwlib.IW_NUM_OPER_MODE 73 | if has_mode and mode == iwlib.IW_MODE_ADHOC: 74 | iwconfig['Cell'] = ffi.string(buf) 75 | else: 76 | iwconfig['Access Point'] = ffi.string(buf) 77 | 78 | if get_ext(iwlib.SIOCGIWRATE): 79 | iwlib.iw_print_bitrate(buf, len(buf), wrq.u.bitrate.value) 80 | iwconfig['BitRate'] = ffi.string(buf) 81 | 82 | if get_ext(iwlib.SIOCGIWRATE): 83 | iwlib.iw_print_bitrate(buf, len(buf), wrq.u.bitrate.value) 84 | iwconfig['BitRate'] = ffi.string(buf) 85 | 86 | buf = ffi.new('char []', 1024) 87 | wrq.u.data.pointer = buf 88 | wrq.u.data.length = iwlib.IW_ENCODING_TOKEN_MAX 89 | wrq.u.data.flags = 0 90 | if get_ext(iwlib.SIOCGIWENCODE): 91 | flags = wrq.u.data.flags 92 | key_size = wrq.u.data.length 93 | 94 | if flags & iwlib.IW_ENCODE_DISABLED or not key_size: 95 | iwconfig['Key'] = b'off' 96 | else: 97 | key = ffi.new('char []', 1024) 98 | iwlib.iw_print_key(key, len(key), buf, key_size, flags) 99 | iwconfig['Key'] = ffi.string(key) 100 | 101 | essid = ffi.new('char []', iwlib.IW_ESSID_MAX_SIZE+1) 102 | wrq.u.essid.pointer = essid 103 | wrq.u.essid.length = iwlib.IW_ESSID_MAX_SIZE + 1 104 | wrq.u.essid.flags = 0 105 | if get_ext(iwlib.SIOCGIWESSID): 106 | iwconfig['ESSID'] = ffi.string(ffi.cast('char *', (wrq.u.essid.pointer))) 107 | wrq.u.essid.length = iwlib.IW_ESSID_MAX_SIZE + 1 108 | wrq.u.essid.flags = 0 109 | 110 | if get_ext(iwlib.SIOCGIWMODE): 111 | mode = wrq.u.mode 112 | has_mode = 0 <= mode < iwlib.IW_NUM_OPER_MODE 113 | if has_mode: 114 | iwconfig['Mode'] = ffi.string(iwlib.iw_operation_mode[mode]) 115 | 116 | stats = ffi.new('iwstats *') 117 | range = ffi.new('iwrange *') 118 | 119 | has_range = int(iwlib.iw_get_range_info(sock, interface, range) >= 0) 120 | if iwlib.iw_get_stats(sock, interface, stats, range, has_range) >= 0: 121 | iwconfig['stats'] = _parse_stats(stats) 122 | 123 | return iwconfig 124 | 125 | 126 | def set_essid(interface, essid): 127 | """ 128 | Set the ESSID of a given interface 129 | 130 | Arguments: 131 | interface - device to work on (e.g. eth1, wlan0). 132 | essid - ESSID to set. Must be no longer than IW_ESSID_MAX_SIZE (typically 32 characters). 133 | 134 | """ 135 | interface = _get_bytes(interface) 136 | essid = _get_bytes(essid) 137 | 138 | wrq = ffi.new('struct iwreq*') 139 | 140 | with iwlib_socket() as sock: 141 | if essid.lower() in (b'off', b'any'): 142 | wrq.u.essid.flags = 0 143 | essid = b'' 144 | elif essid.lower() == b'on': 145 | buf = ffi.new('char []', iwlib.IW_ESSID_MAX_SIZE+1) 146 | wrq.u.essid.pointer = buf 147 | wrq.u.essid.length = iwlib.IW_ESSID_MAX_SIZE + 1 148 | wrq.u.essid.flags = 0 149 | if iwlib.iw_get_ext(sock, interface, iwlib.SIOCGIWESSID, wrq) < 0: 150 | raise ValueError("Error retrieving previous ESSID: %s" % (os.strerror(ffi.errno))) 151 | wrq.u.essid.flags = 1 152 | elif len(essid) > iwlib.IW_ESSID_MAX_SIZE: 153 | raise ValueError("ESSID '%s' is longer than the maximum %d" % (essid, iwlib.IW_ESSID_MAX_SIZE)) 154 | else: 155 | wrq.u.essid.pointer = ffi.new_handle(essid) 156 | wrq.u.essid.length = len(essid) 157 | wrq.u.essid.flags = 1 158 | 159 | if iwlib.iw_get_kernel_we_version() < 21: 160 | wrq.u.essid.length += 1 161 | 162 | if iwlib.iw_set_ext(sock, interface, iwlib.SIOCSIWESSID, wrq) < 0: 163 | errno = ffi.errno 164 | strerror = "Couldn't set essid on device '%s': %s" % (interface.decode('utf8'), os.strerror(errno)) 165 | raise OSError(errno, strerror) 166 | -------------------------------------------------------------------------------- /wifi_survey_heatmap/vendor/iwlib/_iwlib_build.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2009-2012 Red Hat, Inc. 2 | # Copyright (C) 2013-2014 Nathan Hoad. 3 | # 4 | # Interface with iwlib by Nathan Hoad . 5 | # 6 | # This application is free software; you can redistribute it and/or modify it 7 | # under the terms of the GNU General Public License as published by the Free 8 | # Software Foundation; version 2. 9 | # 10 | # This application is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | # General Public License for more details. 14 | 15 | from cffi import FFI 16 | 17 | ffibuilder = FFI() 18 | 19 | 20 | funcs = """ 21 | double iw_freq2float(const iwfreq *in); 22 | int iw_get_ext(int sock, char *interface, int flag, struct iwreq *req); 23 | int iw_get_kernel_we_version(); 24 | int iw_get_range_info(int skfd, const char *ifname, iwrange *range); 25 | int iw_get_stats(int skfd, const char *ifname, iwstats *stats, iwrange *range, int has_range); 26 | int iw_scan(int sock, char *ifname, int we_version, wireless_scan_head *context); 27 | int iw_set_ext(int sock, char *interface, int flag, struct iwreq *req); 28 | int iw_sockets_open(); 29 | void iw_ether_ntop(const struct ether_addr *eth, char *buf); 30 | void iw_print_bitrate(char *buffer, int buflen, int bitrate); 31 | void iw_print_freq_value(char *buffer, int buflen, double freq); 32 | void iw_sockets_close(int sock); 33 | int ioctl(int fildes, unsigned long int request, ...); 34 | """ 35 | 36 | externs = """ 37 | extern const char * const iw_operation_mode[]; 38 | """ 39 | 40 | defs = """ 41 | #define IW_ESSID_MAX_SIZE ... 42 | #define SIOCSIWESSID ... 43 | #define SIOCGIWESSID ... 44 | #define SIOCSIWCOMMIT ... 45 | #define SIOCGIWNAME ... 46 | #define SIOCSIWNWID ... 47 | #define SIOCGIWNWID ... 48 | #define SIOCSIWFREQ ... 49 | #define SIOCGIWFREQ ... 50 | #define SIOCSIWMODE ... 51 | #define SIOCGIWMODE ... 52 | #define SIOCSIWSENS ... 53 | #define SIOCGIWSENS ... 54 | #define SIOCSIWRANGE ... 55 | #define SIOCGIWRANGE ... 56 | #define SIOCSIWPRIV ... 57 | #define SIOCGIWPRIV ... 58 | #define SIOCSIWSTATS ... 59 | #define SIOCGIWSTATS ... 60 | #define SIOCSIWSPY ... 61 | #define SIOCGIWSPY ... 62 | #define SIOCSIWTHRSPY ... 63 | #define SIOCGIWTHRSPY ... 64 | #define SIOCSIWAP ... 65 | #define SIOCGIWAP ... 66 | #define SIOCGIWAPLIST ... 67 | #define SIOCSIWSCAN ... 68 | #define SIOCGIWSCAN ... 69 | #define SIOCSIWESSID ... 70 | #define SIOCGIWESSID ... 71 | #define SIOCSIWNICKN ... 72 | #define SIOCGIWNICKN ... 73 | #define SIOCSIWRATE ... 74 | #define SIOCGIWRATE ... 75 | #define SIOCSIWRTS ... 76 | #define SIOCGIWRTS ... 77 | #define SIOCSIWFRAG ... 78 | #define SIOCGIWFRAG ... 79 | #define SIOCSIWTXPOW ... 80 | #define SIOCGIWTXPOW ... 81 | #define SIOCSIWRETRY ... 82 | #define SIOCGIWRETRY ... 83 | #define SIOCSIWENCODE ... 84 | #define SIOCGIWENCODE ... 85 | #define SIOCSIWPOWER ... 86 | #define SIOCGIWPOWER ... 87 | #define SIOCSIWMODUL ... 88 | #define SIOCGIWMODUL ... 89 | #define SIOCSIWGENIE ... 90 | #define SIOCGIWGENIE ... 91 | #define SIOCSIWMLME ... 92 | #define SIOCSIWAUTH ... 93 | #define SIOCGIWAUTH ... 94 | #define SIOCSIWENCODEEXT ... 95 | #define SIOCGIWENCODEEXT ... 96 | #define SIOCSIWPMKSA ... 97 | #define SIOCIWFIRSTPRIV ... 98 | #define SIOCIWLASTPRIV ... 99 | 100 | #define IW_MODE_AUTO ... 101 | #define IW_MODE_ADHOC ... 102 | #define IW_MODE_INFRA ... 103 | #define IW_MODE_MASTER ... 104 | #define IW_MODE_REPEAT ... 105 | #define IW_MODE_SECOND ... 106 | #define IW_MODE_MONITOR ... 107 | 108 | #define IW_NUM_OPER_MODE ... 109 | #define IW_ENCODING_TOKEN_MAX ... 110 | #define IW_ENCODE_DISABLED ... 111 | 112 | #define IFNAMSIZ ... 113 | #define SIOCGIFFLAGS ... 114 | """ 115 | 116 | structs = """ 117 | typedef struct sockaddr { 118 | char sa_data[14]; 119 | ...; 120 | } sockaddr; 121 | 122 | typedef struct iw_param { 123 | int value; 124 | unsigned char disabled; 125 | ...; 126 | } iwparam; 127 | 128 | struct wireless_config { 129 | int has_mode; 130 | int mode; 131 | int essid_on; 132 | char essid[]; 133 | int has_freq; 134 | double freq; 135 | int freq_flags; 136 | ...; 137 | }; 138 | 139 | typedef struct iw_statistics { 140 | struct iw_quality qual; 141 | ...; 142 | } iwstats; 143 | 144 | typedef struct wireless_scan { 145 | struct wireless_scan *next; 146 | int has_ap_addr; 147 | int has_stats; 148 | int has_maxbitrate; 149 | iwparam maxbitrate; 150 | iwstats stats; 151 | struct wireless_config b; 152 | sockaddr ap_addr; 153 | ...; 154 | } wireless_scan; 155 | 156 | typedef struct wireless_scan_head { 157 | wireless_scan *result; 158 | int retry; 159 | } wireless_scan_head; 160 | 161 | struct iw_quality { 162 | unsigned char qual; 163 | unsigned char level; 164 | unsigned char noise; 165 | unsigned char updated; 166 | ...; 167 | }; 168 | 169 | struct iw_range { 170 | unsigned char we_version_compiled; 171 | struct iw_quality max_qual; 172 | ...; 173 | }; 174 | 175 | typedef struct iw_range iwrange; 176 | 177 | struct iw_point { 178 | void *pointer; 179 | unsigned short length; 180 | unsigned short flags; 181 | }; 182 | 183 | typedef struct iw_freq { 184 | int m; 185 | short e; 186 | unsigned char i; 187 | unsigned char flags; 188 | } iwfreq; 189 | 190 | union iwreq_data { 191 | struct iw_point essid; 192 | struct iw_point data; 193 | struct iw_freq freq; 194 | sockaddr ap_addr; 195 | int mode; 196 | iwparam bitrate; 197 | iwparam power; 198 | iwparam nwid; 199 | ...; 200 | }; 201 | 202 | struct iwreq { 203 | union iwreq_data u; 204 | char ifr_name[...]; 205 | ...; 206 | }; 207 | """ 208 | 209 | ffibuilder.set_source( 210 | "wifi_survey_heatmap.vendor.iwlib._iwlib", 211 | "#include ", 212 | libraries=['iw'] 213 | ) 214 | ffibuilder.cdef(structs + externs + defs + funcs) 215 | 216 | iwlib = ffibuilder.verify("#include ", libraries=['iw']) 217 | 218 | if __name__ == "__main__": 219 | ffibuilder.compile() 220 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | python-wifi-survey-heatmap 2 | ========================== 3 | 4 | .. image:: https://www.repostatus.org/badges/latest/wip.svg 5 | :alt: Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public. 6 | :target: https://www.repostatus.org/#wip 7 | 8 | A Python application for Linux machines to perform WiFi site surveys and present 9 | the results as a heatmap overlayed on a floorplan. 10 | 11 | This is very rough, very alpha code. The heatmap generation code is roughly based on 12 | `Beau Gunderson's MIT-licensed wifi-heatmap code `_. 13 | 14 | Installation and Dependencies 15 | ----------------------------- 16 | 17 | * The Python `iwlib `_ package, which needs cffi and the Linux ``wireless_tools`` package. 18 | * The Python `iperf3 `_ package, which needs `iperf3 `_ installed on your system. 19 | * `wxPython Phoenix `_, which unfortunately must be installed using OS packages or built from source. 20 | * An iperf3 server running on another system on the LAN, as described below. 21 | 22 | Recommended installation is via ``python setup.py develop`` in a virtualenv setup with ``--system-site-packages`` (for the above dependencies). 23 | 24 | Tested with Python 3.7. 25 | 26 | Data Collection 27 | --------------- 28 | 29 | At each survey location, data collection should take 45-60 seconds. The data collected is currently: 30 | 31 | * 10-second iperf3 measurement, TCP, client (this app) sending to server, default iperf3 options 32 | * 10-second iperf3 measurement, TCP, server sending to client, default iperf3 options 33 | * 10-second iperf3 measurement, UDP, client (this app) sending to server, default iperf3 options 34 | * ``iwconfig`` capture for current AP/ESSID/BSSID, frequency, bitrate, and quality/level/noise stats 35 | * ``iwlist`` scan of all visible access points 36 | 37 | Usage 38 | ----- 39 | 40 | Server Setup 41 | ++++++++++++ 42 | 43 | On the system you're using as the ``iperf3`` server, run ``iperf3 -s`` to start iperf3 in server mode in the foreground. 44 | By default it will use TCP and UDP ports 5201 for communication, and these must be open in your firewall (at least from the client machine). 45 | Ideally, you should be running the same exact iperf3 version on both machines. 46 | 47 | Performing a Survey 48 | +++++++++++++++++++ 49 | 50 | The survey tool (``wifi-survey``) must be run as root or via ``sudo`` in order to use iwconfig/iwlist. 51 | 52 | First connect to the network that you want to survey. Then, run ``sudo wifi-survey INTERFACE SERVER PNG Title`` where: 53 | 54 | * ``INTERFACE`` is the name of your Wireless interface (e.g. ``wlp3s0``) 55 | * ``SERVER`` is the IP address or hostname of the iperf3 server 56 | * ``PNG`` is the path to a floorplan PNG file to use as the background for the map; see `examples/example_floorplan.png `_ for an example. In order to compare multiple surveys it may be helpful to pre-mark your measurement points on the floorplan, like `examples/example_with_marks.png /dev/null 2>&1; echo $$?), 1) 12 | $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) 13 | endif 14 | 15 | # Internal variables. 16 | PAPEROPT_a4 = -D latex_paper_size=a4 17 | PAPEROPT_letter = -D latex_paper_size=letter 18 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source 19 | # the i18n builder cannot share the environment and doctrees with the others 20 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source 21 | 22 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext 23 | 24 | help: 25 | @echo "Please use \`make ' where is one of" 26 | @echo " html to make standalone HTML files" 27 | @echo " dirhtml to make HTML files named index.html in directories" 28 | @echo " singlehtml to make a single large HTML file" 29 | @echo " pickle to make pickle files" 30 | @echo " json to make JSON files" 31 | @echo " htmlhelp to make HTML files and a HTML help project" 32 | @echo " qthelp to make HTML files and a qthelp project" 33 | @echo " applehelp to make an Apple Help Book" 34 | @echo " devhelp to make HTML files and a Devhelp project" 35 | @echo " epub to make an epub" 36 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 37 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 38 | @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" 39 | @echo " text to make text files" 40 | @echo " man to make manual pages" 41 | @echo " texinfo to make Texinfo files" 42 | @echo " info to make Texinfo files and run them through makeinfo" 43 | @echo " gettext to make PO message catalogs" 44 | @echo " changes to make an overview of all changed/added/deprecated items" 45 | @echo " xml to make Docutils-native XML files" 46 | @echo " pseudoxml to make pseudoxml-XML files for display purposes" 47 | @echo " linkcheck to check all external links for integrity" 48 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 49 | @echo " coverage to run coverage check of the documentation (if enabled)" 50 | 51 | clean: 52 | rm -rf $(BUILDDIR)/* 53 | 54 | html: 55 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 56 | @echo 57 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 58 | 59 | dirhtml: 60 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 61 | @echo 62 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 63 | 64 | singlehtml: 65 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 66 | @echo 67 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 68 | 69 | pickle: 70 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 71 | @echo 72 | @echo "Build finished; now you can process the pickle files." 73 | 74 | json: 75 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 76 | @echo 77 | @echo "Build finished; now you can process the JSON files." 78 | 79 | htmlhelp: 80 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 81 | @echo 82 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 83 | ".hhp project file in $(BUILDDIR)/htmlhelp." 84 | 85 | qthelp: 86 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 87 | @echo 88 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 89 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 90 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/wifi-survey-heatmap.qhcp" 91 | @echo "To view the help file:" 92 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/wifi-survey-heatmap.qhc" 93 | 94 | applehelp: 95 | $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp 96 | @echo 97 | @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." 98 | @echo "N.B. You won't be able to view it unless you put it in" \ 99 | "~/Library/Documentation/Help or install it in your application" \ 100 | "bundle." 101 | 102 | devhelp: 103 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 104 | @echo 105 | @echo "Build finished." 106 | @echo "To view the help file:" 107 | @echo "# mkdir -p $$HOME/.local/share/devhelp/wifi-survey-heatmap" 108 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/wifi-survey-heatmap" 109 | @echo "# devhelp" 110 | 111 | epub: 112 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 113 | @echo 114 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 115 | 116 | latex: 117 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 118 | @echo 119 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 120 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 121 | "(use \`make latexpdf' here to do that automatically)." 122 | 123 | latexpdf: 124 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 125 | @echo "Running LaTeX files through pdflatex..." 126 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 127 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 128 | 129 | latexpdfja: 130 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 131 | @echo "Running LaTeX files through platex and dvipdfmx..." 132 | $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja 133 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 134 | 135 | text: 136 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 137 | @echo 138 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 139 | 140 | man: 141 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 142 | @echo 143 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 144 | 145 | texinfo: 146 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 147 | @echo 148 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 149 | @echo "Run \`make' in that directory to run these through makeinfo" \ 150 | "(use \`make info' here to do that automatically)." 151 | 152 | info: 153 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 154 | @echo "Running Texinfo files through makeinfo..." 155 | make -C $(BUILDDIR)/texinfo info 156 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 157 | 158 | gettext: 159 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 160 | @echo 161 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 162 | 163 | changes: 164 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 165 | @echo 166 | @echo "The overview file is in $(BUILDDIR)/changes." 167 | 168 | linkcheck: 169 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 170 | @echo 171 | @echo "Link check complete; look for any errors in the above output " \ 172 | "or in $(BUILDDIR)/linkcheck/output.txt." 173 | 174 | doctest: 175 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 176 | @echo "Testing of doctests in the sources finished, look at the " \ 177 | "results in $(BUILDDIR)/doctest/output.txt." 178 | 179 | coverage: 180 | $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage 181 | @echo "Testing of coverage in the sources finished, look at the " \ 182 | "results in $(BUILDDIR)/coverage/python.txt." 183 | 184 | xml: 185 | $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml 186 | @echo 187 | @echo "Build finished. The XML files are in $(BUILDDIR)/xml." 188 | 189 | pseudoxml: 190 | $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml 191 | @echo 192 | @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." 193 | -------------------------------------------------------------------------------- /docs/source/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # wifi-survey-heatmap documentation build configuration file, created by 4 | # sphinx-quickstart on Sat Jun 6 16:12:56 2015. 5 | # 6 | # This file is execfile()d with the current directory set to its 7 | # containing dir. 8 | # 9 | # Note that not all possible configuration values are present in this 10 | # autogenerated file. 11 | # 12 | # All configuration values have a default; values that are commented out 13 | # serve to show the default. 14 | 15 | import sys 16 | import os 17 | import re 18 | # to let sphinx find the actual source... 19 | sys.path.insert(0, os.path.abspath("../..")) 20 | from wifi_survey_heatmap.version import VERSION 21 | import sphinx.environment 22 | from docutils.utils import get_source_line 23 | 24 | # If extensions (or modules to document with autodoc) are in another directory, 25 | # add these directories to sys.path here. If the directory is relative to the 26 | # documentation root, use os.path.abspath to make it absolute, like shown here. 27 | #sys.path.insert(0, os.path.abspath('.')) 28 | 29 | is_rtd = os.environ.get('READTHEDOCS', None) != 'True' 30 | readthedocs_version = os.environ.get('READTHEDOCS_VERSION', '') 31 | 32 | rtd_version = VERSION 33 | 34 | if (readthedocs_version in ['stable', 'latest', 'master'] or 35 | re.match(r'^\d+\.\d+\.\d+', readthedocs_version)): 36 | # this is a tag or stable/latest/master; show the actual version 37 | rtd_version = VERSION 38 | 39 | # -- General configuration ------------------------------------------------ 40 | 41 | # If your documentation needs a minimal Sphinx version, state it here. 42 | #needs_sphinx = '1.0' 43 | 44 | # Add any Sphinx extension module names here, as strings. They can be 45 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 46 | # ones. 47 | extensions = [ 48 | 'sphinx.ext.autodoc', 49 | 'sphinx.ext.intersphinx', 50 | 'sphinx.ext.todo', 51 | 'sphinx.ext.coverage', 52 | 'sphinx.ext.viewcode', 53 | ] 54 | 55 | # Add any paths that contain templates here, relative to this directory. 56 | templates_path = ['_templates'] 57 | 58 | # The suffix(es) of source filenames. 59 | # You can specify multiple suffix as a list of string: 60 | # source_suffix = ['.rst', '.md'] 61 | source_suffix = '.rst' 62 | 63 | # The encoding of source files. 64 | #source_encoding = 'utf-8-sig' 65 | 66 | # The master toctree document. 67 | master_doc = 'index' 68 | 69 | # General information about the project. 70 | project = u'wifi-survey-heatmap' 71 | copyright = u'2018 Jason Antman' 72 | author = u'Jason Antman' 73 | 74 | # The version info for the project you're documenting, acts as replacement for 75 | # |version| and |release|, also used in various other places throughout the 76 | # built documents. 77 | # 78 | # The short X.Y version. 79 | version = rtd_version 80 | # The full version, including alpha/beta/rc tags. 81 | release = version 82 | 83 | # The language for content autogenerated by Sphinx. Refer to documentation 84 | # for a list of supported languages. 85 | # 86 | # This is also used if you do content translation via gettext catalogs. 87 | # Usually you set "language" from the command line for these cases. 88 | language = None 89 | 90 | # There are two options for replacing |today|: either, you set today to some 91 | # non-false value, then it is used: 92 | #today = '' 93 | # Else, today_fmt is used as the format for a strftime call. 94 | #today_fmt = '%B %d, %Y' 95 | 96 | # List of patterns, relative to source directory, that match files and 97 | # directories to ignore when looking for source files. 98 | exclude_patterns = [] 99 | 100 | # The reST default role (used for this markup: `text`) to use for all 101 | # documents. 102 | #default_role = None 103 | 104 | # If true, '()' will be appended to :func: etc. cross-reference text. 105 | #add_function_parentheses = True 106 | 107 | # If true, the current module name will be prepended to all description 108 | # unit titles (such as .. function::). 109 | #add_module_names = True 110 | 111 | # If true, sectionauthor and moduleauthor directives will be shown in the 112 | # output. They are ignored by default. 113 | #show_authors = False 114 | 115 | # The name of the Pygments (syntax highlighting) style to use. 116 | pygments_style = 'sphinx' 117 | 118 | # A list of ignored prefixes for module index sorting. 119 | #modindex_common_prefix = [] 120 | 121 | # If true, keep warnings as "system message" paragraphs in the built documents. 122 | #keep_warnings = False 123 | 124 | # If true, `todo` and `todoList` produce output, else they produce nothing. 125 | todo_include_todos = True 126 | 127 | 128 | # -- Options for HTML output ---------------------------------------------- 129 | 130 | if is_rtd: 131 | import sphinx_rtd_theme 132 | html_theme = 'sphinx_rtd_theme' 133 | html_theme_path = [ 134 | sphinx_rtd_theme.get_html_theme_path(), 135 | ] 136 | html_static_path = ['_static'] 137 | htmlhelp_basename = 'wifi-survey-heatmapdoc' 138 | 139 | #html_theme_options = { 140 | # 'analytics_id': 'Your-ID-Here', 141 | #} 142 | 143 | # The name for this set of Sphinx documents. If None, it defaults to 144 | # " v documentation". 145 | html_title = 'v{v} - Description of Package Here'.format(v=version) 146 | 147 | # Add any extra paths that contain custom files (such as robots.txt or 148 | # .htaccess) here, relative to this directory. These files are copied 149 | # directly to the root of the documentation. 150 | #html_extra_path = [] 151 | 152 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 153 | # using the given strftime format. 154 | html_last_updated_fmt = '%b %d, %Y' 155 | 156 | # If true, SmartyPants will be used to convert quotes and dashes to 157 | # typographically correct entities. 158 | #html_use_smartypants = True 159 | 160 | # Custom sidebar templates, maps document names to template names. 161 | #html_sidebars = {} 162 | 163 | # Additional templates that should be rendered to pages, maps page names to 164 | # template names. 165 | #html_additional_pages = {} 166 | 167 | # If false, no module index is generated. 168 | #html_domain_indices = True 169 | 170 | # If false, no index is generated. 171 | #html_use_index = True 172 | 173 | # If true, the index is split into individual pages for each letter. 174 | #html_split_index = False 175 | 176 | # If true, links to the reST sources are added to the pages. 177 | #html_show_sourcelink = True 178 | 179 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 180 | #html_show_sphinx = True 181 | 182 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 183 | #html_show_copyright = True 184 | 185 | # If true, an OpenSearch description file will be output, and all pages will 186 | # contain a tag referring to it. The value of this option must be the 187 | # base URL from which the finished HTML is served. 188 | #html_use_opensearch = '' 189 | 190 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 191 | #html_file_suffix = None 192 | 193 | # Language to be used for generating the HTML full-text search index. 194 | # Sphinx supports the following languages: 195 | # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' 196 | # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' 197 | #html_search_language = 'en' 198 | 199 | # A dictionary with options for the search language support, empty by default. 200 | # Now only 'ja' uses this config value 201 | #html_search_options = {'type': 'default'} 202 | 203 | # The name of a javascript file (relative to the configuration directory) that 204 | # implements a search results scorer. If empty, the default will be used. 205 | #html_search_scorer = 'scorer.js' 206 | 207 | # Output file base name for HTML help builder. 208 | #htmlhelp_basename = 'wifi-survey-heatmapdoc' 209 | 210 | # -- Options for LaTeX output --------------------------------------------- 211 | 212 | latex_elements = { 213 | # The paper size ('letterpaper' or 'a4paper'). 214 | #'papersize': 'letterpaper', 215 | 216 | # The font size ('10pt', '11pt' or '12pt'). 217 | #'pointsize': '10pt', 218 | 219 | # Additional stuff for the LaTeX preamble. 220 | #'preamble': '', 221 | 222 | # Latex figure (float) alignment 223 | #'figure_align': 'htbp', 224 | } 225 | 226 | # Grouping the document tree into LaTeX files. List of tuples 227 | # (source start file, target name, title, 228 | # author, documentclass [howto, manual, or own class]). 229 | latex_documents = [ 230 | (master_doc, 'wifi-survey-heatmap.tex', u'wifi-survey-heatmap Documentation', 231 | u'Jason Antman', 'manual'), 232 | ] 233 | 234 | # The name of an image file (relative to this directory) to place at the top of 235 | # the title page. 236 | #latex_logo = None 237 | 238 | # For "manual" documents, if this is true, then toplevel headings are parts, 239 | # not chapters. 240 | #latex_use_parts = False 241 | 242 | # If true, show page references after internal links. 243 | #latex_show_pagerefs = False 244 | 245 | # If true, show URL addresses after external links. 246 | #latex_show_urls = False 247 | 248 | # Documents to append as an appendix to all manuals. 249 | #latex_appendices = [] 250 | 251 | # If false, no module index is generated. 252 | #latex_domain_indices = True 253 | 254 | 255 | # -- Options for manual page output --------------------------------------- 256 | 257 | # One entry per manual page. List of tuples 258 | # (source start file, name, description, authors, manual section). 259 | man_pages = [ 260 | (master_doc, 'wifi-survey-heatmap', u'wifi-survey-heatmap Documentation', 261 | [author], 1) 262 | ] 263 | 264 | # If true, show URL addresses after external links. 265 | #man_show_urls = False 266 | 267 | 268 | # -- Options for Texinfo output ------------------------------------------- 269 | 270 | # Grouping the document tree into Texinfo files. List of tuples 271 | # (source start file, target name, title, author, 272 | # dir menu entry, description, category) 273 | texinfo_documents = [ 274 | (master_doc, 'wifi-survey-heatmap', u'wifi-survey-heatmap Documentation', 275 | author, 'wifi-survey-heatmap', 'One line description of project.', 276 | 'Miscellaneous'), 277 | ] 278 | 279 | # Documents to append as an appendix to all manuals. 280 | #texinfo_appendices = [] 281 | 282 | # If false, no module index is generated. 283 | #texinfo_domain_indices = True 284 | 285 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 286 | #texinfo_show_urls = 'footnote' 287 | 288 | # If true, do not generate a @detailmenu in the "Top" node's menu. 289 | #texinfo_no_detailmenu = False 290 | 291 | 292 | # Example configuration for intersphinx: refer to the Python standard library. 293 | intersphinx_mapping = { 294 | 'https://docs.python.org/3/': None, 295 | } 296 | 297 | autoclass_content = 'class' 298 | autodoc_default_flags = ['members', 'undoc-members', 'private-members', 'show-inheritance'] 299 | 300 | linkcheck_ignore = [ 301 | r'https?://landscape\.io.*', 302 | r'https?://www\.virtualenv\.org.*', 303 | r'https?://.*\.readthedocs\.org.*', 304 | r'https?://codecov\.io.*', 305 | r'https?://.*readthedocs\.org.*', 306 | r'https?://pypi\.python\.org/pypi/wifi-survey-heatmap' 307 | ] 308 | 309 | # exclude module docstrings - see http://stackoverflow.com/a/18031024/211734 310 | def remove_module_docstring(app, what, name, obj, options, lines): 311 | if what == "module": 312 | del lines[:] 313 | 314 | # ignore non-local image warnings 315 | def _warn_node(self, msg, node, **kwargs): 316 | if not msg.startswith('nonlocal image URI found:'): 317 | self._warnfunc(msg, '%s:%s' % get_source_line(node)) 318 | 319 | sphinx.environment.BuildEnvironment.warn_node = _warn_node 320 | 321 | def setup(app): 322 | app.connect("autodoc-process-docstring", remove_module_docstring) 323 | -------------------------------------------------------------------------------- /wifi_survey_heatmap/ui.py: -------------------------------------------------------------------------------- 1 | """ 2 | The latest version of this package is available at: 3 | 4 | 5 | ################################################################################## 6 | Copyright 2017 Jason Antman 7 | 8 | This file is part of wifi-survey-heatmap, also known as wifi-survey-heatmap. 9 | 10 | wifi-survey-heatmap is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU Affero General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | wifi-survey-heatmap is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU Affero General Public License for more details. 19 | 20 | You should have received a copy of the GNU Affero General Public License 21 | along with wifi-survey-heatmap. If not, see . 22 | 23 | The Copyright and Authors attributions contained herein may not be removed or 24 | otherwise altered, except to add the Author attribution of a contributor to 25 | this work. (Additional Terms pursuant to Section 7b of the AGPL v3) 26 | ################################################################################## 27 | While not legally required, I sincerely request that anyone who finds 28 | bugs please submit them at or 29 | to me via email, and that you send any contributions or improvements 30 | either as a pull request on GitHub, or to me via email. 31 | ################################################################################## 32 | 33 | AUTHORS: 34 | Jason Antman 35 | ################################################################################## 36 | """ 37 | 38 | import sys 39 | import argparse 40 | import logging 41 | import wx 42 | import json 43 | import os 44 | 45 | from wifi_survey_heatmap.collector import Collector 46 | 47 | FORMAT = "[%(asctime)s %(levelname)s] %(message)s" 48 | logging.basicConfig(level=logging.WARNING, format=FORMAT) 49 | logger = logging.getLogger() 50 | 51 | 52 | RESULT_FIELDS = [ 53 | 'error', 54 | 'time', 55 | 'timesecs', 56 | 'protocol', 57 | 'num_streams', 58 | 'blksize', 59 | 'omit', 60 | 'duration', 61 | 'sent_bytes', 62 | 'sent_bps', 63 | 'received_bytes', 64 | 'received_bps', 65 | 'sent_kbps', 66 | 'sent_Mbps', 67 | 'sent_kB_s', 68 | 'sent_MB_s', 69 | 'received_kbps', 70 | 'received_Mbps', 71 | 'received_kB_s', 72 | 'received_MB_s', 73 | 'retransmits', 74 | 'bytes', 75 | 'bps', 76 | 'jitter_ms', 77 | 'kbps', 78 | 'Mbps', 79 | 'kB_s', 80 | 'MB_s', 81 | 'packets', 82 | 'lost_packets', 83 | 'lost_percent', 84 | 'seconds' 85 | ] 86 | 87 | 88 | class SurveyPoint(object): 89 | 90 | def __init__(self, parent, x, y): 91 | self.parent = parent 92 | self.x = x 93 | self.y = y 94 | self.is_finished = False 95 | self.is_failed = False 96 | self.result = {} 97 | 98 | def set_result(self, res): 99 | self.result = res 100 | 101 | @property 102 | def as_dict(self): 103 | return { 104 | 'x': self.x, 105 | 'y': self.y, 106 | 'result': self.result, 107 | 'failed': self.is_failed 108 | } 109 | 110 | def set_is_failed(self): 111 | self.is_failed = True 112 | 113 | def set_is_finished(self): 114 | self.is_finished = True 115 | 116 | def draw(self, dc): 117 | color = 'green' 118 | if not self.is_finished: 119 | color = 'yellow' 120 | if self.is_failed: 121 | color = 'red' 122 | dc.SetBrush(wx.Brush(color, wx.SOLID)) 123 | dc.DrawCircle(self.x, self.y, 20) 124 | 125 | 126 | class SafeEncoder(json.JSONEncoder): 127 | 128 | def default(self, obj): 129 | if isinstance(obj, type(b'')): 130 | return obj.decode() 131 | return json.JSONEncoder.default(self, obj) 132 | 133 | 134 | class FloorplanPanel(wx.Panel): 135 | 136 | def __init__(self, parent): 137 | super(FloorplanPanel, self).__init__(parent) 138 | self.parent = parent 139 | self.img_path = parent.img_path 140 | self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) 141 | self.Bind(wx.EVT_LEFT_UP, self.onClick) 142 | self.Bind(wx.EVT_PAINT, self.on_paint) 143 | self.survey_points = [] 144 | self.data_filename = '%s.json' % self.parent.survey_title 145 | if os.path.exists(self.data_filename): 146 | self._load_file(self.data_filename) 147 | self.collector = Collector(self.parent.interface, self.parent.server) 148 | self.parent.SetStatusText("Ready.") 149 | 150 | def _load_file(self, fpath): 151 | with open(fpath, 'r') as fh: 152 | raw = fh.read() 153 | data = json.loads(raw) 154 | for point in data: 155 | p = SurveyPoint(self, point['x'], point['y']) 156 | p.set_result(point['result']) 157 | p.set_is_finished() 158 | self.survey_points.append(p) 159 | 160 | def OnEraseBackground(self, evt): 161 | """Add a picture to the background""" 162 | dc = evt.GetDC() 163 | if not dc: 164 | dc = wx.ClientDC(self) 165 | rect = self.GetUpdateRegion().GetBox() 166 | dc.SetClippingRect(rect) 167 | dc.Clear() 168 | bmp = wx.Bitmap(self.img_path) 169 | dc.DrawBitmap(bmp, 0, 0) 170 | 171 | def onClick(self, event): 172 | pos = event.GetPosition() 173 | self.parent.SetStatusText('Got click at: %s' % pos) 174 | self.survey_points.append(SurveyPoint(self, pos[0], pos[1])) 175 | self.Refresh() 176 | res = {} 177 | count = 0 178 | for protoname, udp in {'tcp': False, 'udp': True}.items(): 179 | for suffix, reverse in {'': False, '-reverse': True}.items(): 180 | if udp and reverse: 181 | logger.warning('Skipping reverse UDP; always fails') 182 | continue 183 | count += 1 184 | tmp = self.run_iperf(count, udp, reverse) 185 | if tmp is None: 186 | # bail out; abort this survey point 187 | del self.survey_points[-1] 188 | self.parent.SetStatusText('Aborted; ready to retry...') 189 | self.Refresh() 190 | return 191 | # else success 192 | res['%s%s' % (protoname, suffix)] = { 193 | x: getattr(tmp, x, None) for x in RESULT_FIELDS 194 | } 195 | self.parent.SetStatusText('Running iwconfig...') 196 | self.Refresh() 197 | res['iwconfig'] = self.collector.run_iwconfig() 198 | self.parent.SetStatusText('Running iwscan...') 199 | self.Refresh() 200 | res['iwscan'] = self.collector.run_iwscan() 201 | self.survey_points[-1].set_result(res) 202 | self.survey_points[-1].set_is_finished() 203 | self.parent.SetStatusText( 204 | 'Saving to: %s' % self.data_filename 205 | ) 206 | self.Refresh() 207 | res = json.dumps( 208 | [x.as_dict for x in self.survey_points], 209 | cls=SafeEncoder 210 | ) 211 | with open(self.data_filename, 'w') as fh: 212 | fh.write(res) 213 | self.parent.SetStatusText( 214 | 'Saved to %s; ready...' % self.data_filename 215 | ) 216 | self.Refresh() 217 | 218 | def warn(self, message, caption='Warning!'): 219 | dlg = wx.MessageDialog(self.parent, message, caption, 220 | wx.OK | wx.ICON_WARNING) 221 | dlg.ShowModal() 222 | dlg.Destroy() 223 | 224 | def YesNo(self, question, caption='Yes or no?'): 225 | dlg = wx.MessageDialog(self.parent, question, caption, 226 | wx.YES_NO | wx.ICON_QUESTION) 227 | result = dlg.ShowModal() == wx.ID_YES 228 | dlg.Destroy() 229 | return result 230 | 231 | def run_iperf(self, count, udp, reverse): 232 | self.parent.SetStatusText( 233 | 'Running iperf %d/3 (udp=%s, reverse=%s)' % (count, udp, reverse) 234 | ) 235 | self.Refresh() 236 | tmp = self.collector.run_iperf(udp, reverse) 237 | if tmp.error is None: 238 | return tmp 239 | # else this is an error 240 | if tmp.error.startswith('unable to connect to server'): 241 | self.warn( 242 | 'ERROR: Unable to connect to iperf server. Aborting.' 243 | ) 244 | return None 245 | if self.YesNo('iperf error: %s. Retry?' % tmp.error): 246 | self.Refresh() 247 | return self.run_iperf(count, udp, reverse) 248 | # else bail out 249 | return tmp 250 | 251 | def on_paint(self, event=None): 252 | dc = wx.ClientDC(self) 253 | for p in self.survey_points: 254 | p.draw(dc) 255 | 256 | 257 | class MainFrame(wx.Frame): 258 | 259 | def __init__( 260 | self, img_path, interface, server, survey_title, 261 | *args, **kw 262 | ): 263 | super(MainFrame, self).__init__(*args, **kw) 264 | self.img_path = img_path 265 | self.interface = interface 266 | self.server = server 267 | self.survey_title = survey_title 268 | self.CreateStatusBar() 269 | self.pnl = FloorplanPanel(self) 270 | self.makeMenuBar() 271 | 272 | def makeMenuBar(self): 273 | fileMenu = wx.Menu() 274 | fileMenu.AppendSeparator() 275 | exitItem = fileMenu.Append(wx.ID_EXIT) 276 | menuBar = wx.MenuBar() 277 | menuBar.Append(fileMenu, "&File") 278 | self.SetMenuBar(menuBar) 279 | self.Bind(wx.EVT_MENU, self.OnExit, exitItem) 280 | 281 | def OnExit(self, event): 282 | """Close the frame, terminating the application.""" 283 | self.Close(True) 284 | 285 | 286 | def parse_args(argv): 287 | """ 288 | parse arguments/options 289 | 290 | this uses the new argparse module instead of optparse 291 | see: 292 | """ 293 | p = argparse.ArgumentParser(description='wifi survey data collection UI') 294 | p.add_argument('-v', '--verbose', dest='verbose', action='count', default=0, 295 | help='verbose output. specify twice for debug-level output.') 296 | p.add_argument('INTERFACE', type=str, help='Wireless interface name') 297 | p.add_argument('SERVER', type=str, help='iperf3 server IP or hostname') 298 | p.add_argument('IMAGE', type=str, help='Path to background image') 299 | p.add_argument( 300 | 'TITLE', type=str, help='Title for survey (and data filename)' 301 | ) 302 | args = p.parse_args(argv) 303 | return args 304 | 305 | 306 | def set_log_info(): 307 | """set logger level to INFO""" 308 | set_log_level_format(logging.INFO, 309 | '%(asctime)s %(levelname)s:%(name)s:%(message)s') 310 | 311 | 312 | def set_log_debug(): 313 | """set logger level to DEBUG, and debug-level output format""" 314 | set_log_level_format( 315 | logging.DEBUG, 316 | "%(asctime)s [%(levelname)s %(filename)s:%(lineno)s - " 317 | "%(name)s.%(funcName)s() ] %(message)s" 318 | ) 319 | 320 | 321 | def set_log_level_format(level, format): 322 | """ 323 | Set logger level and format. 324 | 325 | :param level: logging level; see the :py:mod:`logging` constants. 326 | :type level: int 327 | :param format: logging formatter format string 328 | :type format: str 329 | """ 330 | formatter = logging.Formatter(fmt=format) 331 | logger.handlers[0].setFormatter(formatter) 332 | logger.setLevel(level) 333 | 334 | 335 | def main(): 336 | args = parse_args(sys.argv[1:]) 337 | 338 | # set logging level 339 | if args.verbose > 1: 340 | set_log_debug() 341 | elif args.verbose == 1: 342 | set_log_info() 343 | 344 | app = wx.App() 345 | frm = MainFrame( 346 | args.IMAGE, args.INTERFACE, args.SERVER, args.TITLE, 347 | None, title='wifi-survey: %s' % args.TITLE 348 | ) 349 | frm.Show() 350 | frm.Maximize(True) 351 | frm.SetStatusText('%s' % frm.pnl.GetSize()) 352 | app.MainLoop() 353 | 354 | 355 | if __name__ == '__main__': 356 | main() 357 | -------------------------------------------------------------------------------- /wifi_survey_heatmap/heatmap.py: -------------------------------------------------------------------------------- 1 | """ 2 | The latest version of this package is available at: 3 | 4 | 5 | ################################################################################## 6 | Copyright 2017 Jason Antman 7 | 8 | This file is part of wifi-survey-heatmap, also known as wifi-survey-heatmap. 9 | 10 | wifi-survey-heatmap is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU Affero General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | wifi-survey-heatmap is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU Affero General Public License for more details. 19 | 20 | You should have received a copy of the GNU Affero General Public License 21 | along with wifi-survey-heatmap. If not, see . 22 | 23 | The Copyright and Authors attributions contained herein may not be removed or 24 | otherwise altered, except to add the Author attribution of a contributor to 25 | this work. (Additional Terms pursuant to Section 7b of the AGPL v3) 26 | ################################################################################## 27 | While not legally required, I sincerely request that anyone who finds 28 | bugs please submit them at or 29 | to me via email, and that you send any contributions or improvements 30 | either as a pull request on GitHub, or to me via email. 31 | ################################################################################## 32 | 33 | AUTHORS: 34 | Jason Antman 35 | ################################################################################## 36 | """ 37 | 38 | import sys 39 | import argparse 40 | import logging 41 | import json 42 | 43 | from collections import defaultdict 44 | import numpy as np 45 | import matplotlib.cm as cm 46 | import matplotlib.pyplot as pp 47 | from scipy.interpolate import Rbf 48 | from pylab import imread, imshow 49 | from matplotlib.offsetbox import AnchoredText 50 | from matplotlib.patheffects import withStroke 51 | import matplotlib 52 | 53 | 54 | FORMAT = "[%(asctime)s %(levelname)s] %(message)s" 55 | logging.basicConfig(level=logging.WARNING, format=FORMAT) 56 | logger = logging.getLogger() 57 | 58 | 59 | WIFI_CHANNELS = { 60 | # center frequency to (channel, bandwidth MHz) 61 | 2412.0: (1, 20.0), 62 | 2417.0: (2, 20.0), 63 | 2422.0: (3, 20.0), 64 | 2427.0: (4, 20.0), 65 | 2432.0: (5, 20.0), 66 | 2437.0: (6, 20.0), 67 | 2442.0: (7, 20.0), 68 | 2447.0: (8, 20.0), 69 | 2452.0: (9, 20.0), 70 | 2457.0: (10, 20.0), 71 | 2462.0: (11, 20.0), 72 | 2467.0: (12, 20.0), 73 | 2472.0: (13, 20.0), 74 | 2484.0: (14, 20.0), 75 | 5160.0: (32, 20.0), 76 | 5170.0: (34, 40.0), 77 | 5180.0: (36, 20.0), 78 | 5190.0: (38, 40.0), 79 | 5200.0: (40, 20.0), 80 | 5210.0: (42, 80.0), 81 | 5220.0: (44, 20.0), 82 | 5230.0: (46, 40.0), 83 | 5240.0: (48, 20.0), 84 | 5250.0: (50, 160.0), 85 | 5260.0: (52, 20.0), 86 | 5270.0: (54, 40.0), 87 | 5280.0: (56, 20.0), 88 | 5290.0: (58, 80.0), 89 | 5300.0: (60, 20.0), 90 | 5310.0: (62, 40.0), 91 | 5320.0: (64, 20.0), 92 | 5340.0: (68, 20.0), 93 | 5480.0: (96, 20.0), 94 | 5500.0: (100, 20.0), 95 | 5510.0: (102, 40.0), 96 | 5520.0: (104, 20.0), 97 | 5530.0: (106, 80.0), 98 | 5540.0: (108, 20.0), 99 | 5550.0: (110, 40.0), 100 | 5560.0: (112, 20.0), 101 | 5570.0: (114, 160.0), 102 | 5580.0: (116, 20.0), 103 | 5590.0: (118, 40.0), 104 | 5600.0: (120, 20.0), 105 | 5610.0: (122, 80.0), 106 | 5620.0: (124, 20.0), 107 | 5630.0: (126, 40.0), 108 | 5640.0: (128, 20.0), 109 | 5660.0: (132, 20.0), 110 | 5670.0: (134, 40.0), 111 | 5680.0: (136, 20.0), 112 | 5690.0: (138, 80.0), 113 | 5700.0: (140, 20.0), 114 | 5710.0: (142, 40.0), 115 | 5720.0: (144, 20.0), 116 | 5745.0: (149, 20.0), 117 | 5755.0: (151, 40.0), 118 | 5765.0: (153, 20.0), 119 | 5775.0: (155, 80.0), 120 | 5785.0: (157, 20.0), 121 | 5795.0: (159, 40.0), 122 | 5805.0: (161, 20.0), 123 | 5825.0: (165, 20.0) 124 | } 125 | 126 | 127 | class HeatMapGenerator(object): 128 | 129 | def __init__(self, image_path, title, ignore_ssids=[]): 130 | self._image_path = image_path 131 | self._title = title 132 | self._ignore_ssids = ignore_ssids 133 | logger.debug( 134 | 'Initialized HeatMapGenerator; image_path=%s title=%s', 135 | self._image_path, self._title 136 | ) 137 | self._layout = imread(self._image_path) 138 | self._image_width = len(self._layout[0]) 139 | self._image_height = len(self._layout) - 1 140 | logger.debug( 141 | 'Loaded image with width=%d height=%d', 142 | self._image_width, self._image_height 143 | ) 144 | with open('%s.json' % self._title, 'r') as fh: 145 | self._data = json.loads(fh.read()) 146 | logger.info('Loaded %d measurement points', len(self._data)) 147 | 148 | def generate(self): 149 | a = defaultdict(list) 150 | for row in self._data: 151 | a['x'].append(row['x']) 152 | a['y'].append(row['y']) 153 | a['rssi'].append(row['result']['iwconfig']['stats']['level']) 154 | a['quality'].append(row['result']['iwconfig']['stats']['quality']) 155 | a['tcp_upload_Mbps'].append(row['result']['tcp']['sent_Mbps']) 156 | a['tcp_download_Mbps'].append( 157 | row['result']['tcp-reverse']['received_Mbps'] 158 | ) 159 | a['udp_Mbps'].append(row['result']['udp']['Mbps']) 160 | a['jitter'].append(row['result']['udp']['jitter_ms']) 161 | for x, y in [ 162 | (0, 0), (0, self._image_height), 163 | (self._image_width, 0), (self._image_width, self._image_height) 164 | ]: 165 | a['x'].append(x) 166 | a['y'].append(y) 167 | for k in a.keys(): 168 | if k in ['x', 'y']: 169 | continue 170 | a[k] = [0 if x is None else x for x in a[k]] 171 | a[k].append(min(a[k])) 172 | self._channel_graphs() 173 | num_x = int(self._image_width / 4) 174 | num_y = int(num_x / (self._image_width / self._image_height)) 175 | x = np.linspace(0, self._image_width, num_x) 176 | y = np.linspace(0, self._image_height, num_y) 177 | gx, gy = np.meshgrid(x, y) 178 | gx, gy = gx.flatten(), gy.flatten() 179 | for k, ptitle in { 180 | 'rssi': 'RSSI (level)', 181 | 'quality': 'iwstats Quality', 182 | 'tcp_upload_Mbps': 'TCP Upload Mbps', 183 | 'tcp_download_Mbps': 'TCP Download Mbps', 184 | 'udp_Mbps': 'UDP Upload Mbps', 185 | 'jitter': 'UDP Jitter (ms)' 186 | }.items(): 187 | self._plot( 188 | a, k, '%s - %s' % (self._title, ptitle), gx, gy, num_x, num_y 189 | ) 190 | 191 | def _channel_to_signal(self): 192 | """ 193 | Return a dictionary of 802.11 channel number to combined "quality" value 194 | for all APs seen on the given channel. This includes interpolation to 195 | overlapping channels based on channel width of each channel. 196 | """ 197 | # build a dict of frequency (GHz) to list of quality values 198 | channels = defaultdict(list) 199 | for row in self._data: 200 | for scan in row['result']['iwscan']: 201 | if scan['ESSID'] in self._ignore_ssids: 202 | continue 203 | channels[scan['Frequency'] / 1000000].append( 204 | scan['stats']['quality'] 205 | ) 206 | # collapse down to dict of frequency (GHz) to average quality (float) 207 | for freq in channels.keys(): 208 | channels[freq] = sum(channels[freq]) / len(channels[freq]) 209 | # build the full dict of frequency to quality for all channels 210 | freq_qual = {x: 0.0 for x in WIFI_CHANNELS.keys()} 211 | # then, update to account for full bandwidth of each channel 212 | for freq, qual in channels.items(): 213 | freq_qual[freq] += qual 214 | for spread in range( 215 | int(freq - (WIFI_CHANNELS[freq][1] / 2.0)), 216 | int(freq + (WIFI_CHANNELS[freq][1] / 2.0) + 1.0) 217 | ): 218 | if spread in freq_qual and spread != freq: 219 | freq_qual[spread] += qual 220 | return { 221 | WIFI_CHANNELS[x][0]: freq_qual[x] for x in freq_qual.keys() 222 | } 223 | 224 | def _plot_channels(self, names, values, title, fname, ticks): 225 | pp.rcParams['figure.figsize'] = ( 226 | self._image_width / 300, self._image_height / 300 227 | ) 228 | fig, ax = pp.subplots() 229 | ax.set_title(title) 230 | ax.bar(names, values) 231 | ax.set_xlabel('Channel') 232 | ax.set_ylabel('Mean Quality') 233 | ax.set_xticks(ticks) 234 | #ax.set_xticklabels(names) 235 | logger.info('Writing plot to: %s', fname) 236 | pp.savefig(fname, dpi=300) 237 | pp.close('all') 238 | 239 | def _channel_graphs(self): 240 | c2s = self._channel_to_signal() 241 | names24 = [] 242 | values24 = [] 243 | names5 = [] 244 | values5 = [] 245 | for ch, val in c2s.items(): 246 | if ch < 15: 247 | names24.append(ch) 248 | values24.append(val) 249 | else: 250 | names5.append(ch) 251 | values5.append(val) 252 | self._plot_channels( 253 | names24, values24, '2.4GHz Channel Utilization', 254 | '%s_%s.png' % ('channels24', self._title), 255 | names24 256 | ) 257 | ticks5 = [ 258 | 38, 46, 54, 62, 102, 110, 118, 126, 134, 142, 151, 159 259 | ] 260 | self._plot_channels( 261 | names5, values5, '5GHz Channel Utilization', 262 | '%s_%s.png' % ('channels5', self._title), 263 | ticks5 264 | ) 265 | 266 | def _add_inner_title(self, ax, title, loc, size=None, **kwargs): 267 | if size is None: 268 | size = dict(size=pp.rcParams['legend.fontsize']) 269 | at = AnchoredText( 270 | title, loc=loc, prop=size, pad=0., borderpad=0.5, frameon=False, 271 | **kwargs 272 | ) 273 | at.set_zorder(200) 274 | ax.add_artist(at) 275 | at.txt._text.set_path_effects( 276 | [withStroke(foreground="w", linewidth=3)] 277 | ) 278 | return at 279 | 280 | def _plot(self, a, key, title, gx, gy, num_x, num_y): 281 | pp.rcParams['figure.figsize'] = ( 282 | self._image_width / 300, self._image_height / 300 283 | ) 284 | pp.title(title) 285 | # Interpolate the data 286 | rbf = Rbf( 287 | a['x'], a['y'], a[key], function='linear' 288 | ) 289 | z = rbf(gx, gy) 290 | z = z.reshape((num_y, num_x)) 291 | # Render the interpolated data to the plot 292 | pp.axis('off') 293 | # begin color mapping 294 | norm = matplotlib.colors.Normalize( 295 | vmin=min(a[key]), vmax=max(a[key]), clip=True 296 | ) 297 | mapper = cm.ScalarMappable(norm=norm, cmap='RdYlBu_r') 298 | # end color mapping 299 | image = pp.imshow( 300 | z, 301 | extent=(0, self._image_width, self._image_height, 0), 302 | cmap='RdYlBu_r', alpha=0.5, zorder=100 303 | ) 304 | pp.colorbar(image) 305 | pp.imshow(self._layout, interpolation='bicubic', zorder=1, alpha=1) 306 | # begin plotting points 307 | for idx in range(0, len(a['x'])): 308 | pp.plot( 309 | a['x'][idx], a['y'][idx], 310 | marker='o', markeredgecolor='black', markeredgewidth=1, 311 | markerfacecolor=mapper.to_rgba(a[key][idx]), markersize=6 312 | ) 313 | # end plotting points 314 | fname = '%s_%s.png' % (key, self._title) 315 | logger.info('Writing plot to: %s', fname) 316 | pp.savefig(fname, dpi=300) 317 | pp.close('all') 318 | 319 | 320 | def parse_args(argv): 321 | """ 322 | parse arguments/options 323 | 324 | this uses the new argparse module instead of optparse 325 | see: 326 | """ 327 | p = argparse.ArgumentParser(description='wifi survey heatmap generator') 328 | p.add_argument('-v', '--verbose', dest='verbose', action='count', default=0, 329 | help='verbose output. specify twice for debug-level output.') 330 | p.add_argument('-i', '--ignore', dest='ignore', action='append', 331 | default=[], help='SSIDs to ignore from channel graph') 332 | p.add_argument('IMAGE', type=str, help='Path to background image') 333 | p.add_argument( 334 | 'TITLE', type=str, help='Title for survey (and data filename)' 335 | ) 336 | args = p.parse_args(argv) 337 | return args 338 | 339 | 340 | def set_log_info(): 341 | """set logger level to INFO""" 342 | set_log_level_format(logging.INFO, 343 | '%(asctime)s %(levelname)s:%(name)s:%(message)s') 344 | 345 | 346 | def set_log_debug(): 347 | """set logger level to DEBUG, and debug-level output format""" 348 | set_log_level_format( 349 | logging.DEBUG, 350 | "%(asctime)s [%(levelname)s %(filename)s:%(lineno)s - " 351 | "%(name)s.%(funcName)s() ] %(message)s" 352 | ) 353 | 354 | 355 | def set_log_level_format(level, format): 356 | """ 357 | Set logger level and format. 358 | 359 | :param level: logging level; see the :py:mod:`logging` constants. 360 | :type level: int 361 | :param format: logging formatter format string 362 | :type format: str 363 | """ 364 | formatter = logging.Formatter(fmt=format) 365 | logger.handlers[0].setFormatter(formatter) 366 | logger.setLevel(level) 367 | 368 | 369 | def main(): 370 | args = parse_args(sys.argv[1:]) 371 | 372 | # set logging level 373 | if args.verbose > 1: 374 | set_log_debug() 375 | elif args.verbose == 1: 376 | set_log_info() 377 | 378 | HeatMapGenerator( 379 | args.IMAGE, args.TITLE, ignore_ssids=args.ignore 380 | ).generate() 381 | 382 | 383 | if __name__ == '__main__': 384 | main() 385 | -------------------------------------------------------------------------------- /wifi_survey_heatmap/vendor/iwlib/COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | 663 | --------------------------------------------------------------------------------