aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2019-05-05 12:26:24 +0200
committerneodarz <neodarz@neodarz.net>2019-05-05 12:26:26 +0200
commitcce51d8a961cb5b6af21cd44b357defc39e1b008 (patch)
tree7315619675f5b7e402069c12160f9d2fc0bfa386
parent3f8786741afa17c30e23186c465fe870b2de9efe (diff)
downloadpyParrotZikTCP-cce51d8a961cb5b6af21cd44b357defc39e1b008.tar.xz
pyParrotZikTCP-cce51d8a961cb5b6af21cd44b357defc39e1b008.zip
Make code compatible with python3 with python2 support
Warning: This is a preparation work for completly remove PyGTK. Because PyGTK is python2 only, most part of the code didn't work. But a last commands send to the headset is fonctional (This is why all this change).
Diffstat (limited to '')
-rw-r--r--parrot_zik/bluetooth_paired_devices.py2
-rw-r--r--parrot_zik/message.py4
-rwxr-xr-xparrot_zik/parrot_zik_tray.py16
-rw-r--r--parrot_zik/resource_manager.py2
4 files changed, 12 insertions, 12 deletions
diff --git a/parrot_zik/bluetooth_paired_devices.py b/parrot_zik/bluetooth_paired_devices.py
index 5f5d443..626c5e6 100644
--- a/parrot_zik/bluetooth_paired_devices.py
+++ b/parrot_zik/bluetooth_paired_devices.py
@@ -59,7 +59,7 @@ class BluetoothCmdDeviceManager(BluetoothDeviceManager):
def get_mac(self):
pipe = Popen(['bluetoothctl'], stdout=PIPE, stdin=PIPE, stderr=STDOUT)
- res = pipe.communicate("exit")
+ res = str(pipe.communicate("exit".encode("UTF-8")))
if len(res) > 0 and res[0]:
match = p.search(res[0])
if match:
diff --git a/parrot_zik/message.py b/parrot_zik/message.py
index 214b6f9..822e057 100644
--- a/parrot_zik/message.py
+++ b/parrot_zik/message.py
@@ -11,14 +11,14 @@ class Message:
def request(self):
message = bytearray()
message.extend(self.header)
- message.extend(bytearray(self.request_string))
+ message.extend(bytearray(self.request_string, 'utf-8'))
return message
@property
def header(self):
header = bytearray([0])
header.append(len(self.request_string) + 3)
- header.append("\x80")
+ header.append(0x80)
return header
@property
diff --git a/parrot_zik/parrot_zik_tray.py b/parrot_zik/parrot_zik_tray.py
index 35931d7..b5fab68 100755
--- a/parrot_zik/parrot_zik_tray.py
+++ b/parrot_zik/parrot_zik_tray.py
@@ -1,11 +1,11 @@
-from parrot_zik.interface.version1 import ParrotZikVersion1Interface
-from parrot_zik.interface.version2 import ParrotZikVersion2Interface
-from parrot_zik import resource_manager
-from parrot_zik import bluetooth_paired_devices
-from parrot_zik.indicator import MenuItem
-from parrot_zik.indicator import Menu
-from parrot_zik.indicator import SysIndicator
-from parrot_zik.utils import repeat
+from interface.version1 import ParrotZikVersion1Interface
+from interface.version2 import ParrotZikVersion2Interface
+import resource_manager
+import bluetooth_paired_devices
+from indicator import MenuItem
+from indicator import Menu
+from indicator import SysIndicator
+from utils import repeat
REFRESH_FREQUENCY = 30000
RECONNECT_FREQUENCY = 5000
diff --git a/parrot_zik/resource_manager.py b/parrot_zik/resource_manager.py
index aa141cb..cd358e1 100644
--- a/parrot_zik/resource_manager.py
+++ b/parrot_zik/resource_manager.py
@@ -45,7 +45,7 @@ class ResourceManagerBase(object):
def send_message(self, message):
try:
- self.sock.send(str(message))
+ self.sock.send(bytes(message.request))
return self.get_answer(message)
except bluetooth.btcommon.BluetoothError:
raise DeviceDisconnected