Repository: joshvillbrandt/wireless

Issue:
Python3 support

Traceback (most recent call last):
  File "/home/xayon/.virtualenvs/smoothie/lib/python3.4/site-packages/rq/worker.py", line 568, in perform_job
    rv = job.perform()
  File "/home/xayon/.virtualenvs/smoothie/lib/python3.4/site-packages/rq/job.py", line 495, in perform
    self._result = self.func(*self.args, **self.kwargs)
  File "./smoothie/plugins/interfaces.py", line 28, in interfaces
    return str(Interfaces())
  File "./smoothie/plugins/__init__.py", line 37, in __init__
    self.run()
  File "./smoothie/plugins/__init__.py", line 78, in run
    self.callback()
  File "./smoothie/plugins/interfaces.py", line 20, in callback
    ifaces = [a for a in Wireless().interfaces()
  File "/home/xayon/.virtualenvs/smoothie/lib/python3.4/site-packages/wireless/Wireless.py", line 21, in __init__
    self._driver_name = self._detectDriver()
  File "/home/xayon/.virtualenvs/smoothie/lib/python3.4/site-packages/wireless/Wireless.py", line 47, in _detectDriver
    if len(response) > 0 and 'not found' not in response:
TypeError: 'str' does not support the buffer interface


Discussion:

Patch:
diff --git a/wireless/Wireless.py b/wireless/Wireless.py
index d9bb653..389dee9 100644
--- a/wireless/Wireless.py
+++ b/wireless/Wireless.py
@@ -8,7 +8,8 @@ from time import sleep
 def cmd(cmd):
     return subprocess.Popen(
         cmd, shell=True,
-        stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.read()
+        stdout=subprocess.PIPE, stderr=subprocess.STDOUT
+    ).stdout.read().decode()
 
 
 # abstracts away wireless connection


Test patch:
diff --git a/tests/TestWireless.py b/tests/TestWireless.py
index 0ca7ec0..941d8d3 100644
--- a/tests/TestWireless.py
+++ b/tests/TestWireless.py
@@ -2,6 +2,7 @@
 
 import unittest
 from wireless import Wireless
+from wireless.Wireless import cmd
 
 
 class TestWireless(unittest.TestCase):
@@ -12,3 +13,26 @@ class TestWireless(unittest.TestCase):
     def test_import(self):
         # if this module loads, then the import worked...
         self.assertTrue(hasattr(Wireless, 'connect'))
+
+
+class TestCMD(unittest.TestCase):
+    """
+        Tests against cmd function.
+    """
+    def setUp(self):
+        self.com = cmd('echo "test_ok"')
+        self.empty_com = cmd('echo -n')
+
+    def test_cmdcomparission(self):
+        """
+            Check if we can test against the output of
+            the current test command
+        """
+        self.assertTrue('test_ok' in self.com)
+
+    def test_cmdlen(self):
+        """
+            Check if the output is > 0 chars.
+        """
+        self.assertFalse(len(self.empty_com) > 0)
+        self.assertTrue(len(self.com) > 0)