Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Make the code compliant with Python 3.3 or higher (@nicolargo) #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Changelog
- Add a __main__.py so that wifi can be invoked using python -mwifi
- Fix argument parsing so that scan is the default argument even with options passed

0.3.9
^^^^^
:release-date: 2018-12-26

- Make the code compliant with Python 3.3 or higher (@nicolargo)

0.3.8
^^^^^
:release-date: 2016-03-11
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ PORT?=8008
test:
python setup.py test

test3:
~/virtualenv/glances-python3.6/bin/python setup.py test


docs:
cd docs && $(MAKE) html

Expand Down
13 changes: 10 additions & 3 deletions tests/test_init.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from unittest import TestCase

from wifi.scan import Cell
import sys

PY3 = sys.version_info[0] == 3


class CorrectInitTest(TestCase):
fields = {"ssid": None,
Expand All @@ -14,9 +18,12 @@ class CorrectInitTest(TestCase):
"quality": None,
"signal": None}


def test_empty_init(self):
tcell = Cell()

for field, value in self.fields.iteritems():
self.assertEqual(value, getattr(tcell, field))
if PY3:
for field, value in self.fields.items():
self.assertEqual(value, getattr(tcell, field))
else:
for field, value in self.fields.iteritems():
self.assertEqual(value, getattr(tcell, field))
5 changes: 5 additions & 0 deletions wifi/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import wifi.subprocess_compat as subprocess
from wifi.utils import db2dbm
from wifi.exceptions import InterfaceError
import sys

PY3 = sys.version_info[0] == 3


class Cell(object):
Expand Down Expand Up @@ -42,6 +45,8 @@ def all(cls, interface):
else:
iwlist_scan = iwlist_scan.decode('utf-8')
cells = map(Cell.from_string, cells_re.split(iwlist_scan)[1:])
if PY3:
cells = list(cells)

return cells

Expand Down