SHA256
1
0
forked from pool/bluez
bluez/bluez-test-2to3.diff

602 lines
21 KiB
Diff

Index: bluez-5.65/test/bluezutils.py
===================================================================
--- bluez-5.65.orig/test/bluezutils.py
+++ bluez-5.65/test/bluezutils.py
@@ -17,7 +17,7 @@ def find_adapter(pattern=None):
def find_adapter_in_objects(objects, pattern=None):
bus = dbus.SystemBus()
- for path, ifaces in objects.items():
+ for path, ifaces in list(objects.items()):
adapter = ifaces.get(ADAPTER_INTERFACE)
if adapter is None:
continue
@@ -37,7 +37,7 @@ def find_device_in_objects(objects, devi
if adapter_pattern:
adapter = find_adapter_in_objects(objects, adapter_pattern)
path_prefix = adapter.object_path
- for path, ifaces in objects.items():
+ for path, ifaces in list(objects.items()):
device = ifaces.get(DEVICE_INTERFACE)
if device is None:
continue
Index: bluez-5.65/test/example-advertisement
===================================================================
--- bluez-5.65.orig/test/example-advertisement
+++ bluez-5.65/test/example-advertisement
@@ -164,7 +164,7 @@ def find_adapter(bus):
DBUS_OM_IFACE)
objects = remote_om.GetManagedObjects()
- for o, props in objects.items():
+ for o, props in list(objects.items()):
if LE_ADVERTISING_MANAGER_IFACE in props:
return o
Index: bluez-5.65/test/example-gatt-client
===================================================================
--- bluez-5.65.orig/test/example-gatt-client
+++ bluez-5.65/test/example-gatt-client
@@ -33,7 +33,7 @@ hr_ctrl_pt_chrc = None
def generic_error_cb(error):
- print('D-Bus call failed: ' + str(error))
+ print(('D-Bus call failed: ' + str(error)))
mainloop.quit()
@@ -69,10 +69,10 @@ def sensor_contact_val_to_str(val):
def body_sensor_val_cb(value):
if len(value) != 1:
- print('Invalid body sensor location value: ' + repr(value))
+ print(('Invalid body sensor location value: ' + repr(value)))
return
- print('Body sensor location value: ' + body_sensor_val_to_str(value[0]))
+ print(('Body sensor location value: ' + body_sensor_val_to_str(value[0])))
def hr_msrmt_start_notify_cb():
@@ -104,12 +104,12 @@ def hr_msrmt_changed_cb(iface, changed_p
hr_msrmt = value[1] | (value[2] << 8)
next_ind = 3
- print('\tHR: ' + str(int(hr_msrmt)))
- print('\tSensor Contact status: ' +
- sensor_contact_val_to_str(sc_status))
+ print(('\tHR: ' + str(int(hr_msrmt))))
+ print(('\tSensor Contact status: ' +
+ sensor_contact_val_to_str(sc_status)))
if ee_status:
- print('\tEnergy Expended: ' + str(int(value[next_ind])))
+ print(('\tEnergy Expended: ' + str(int(value[next_ind]))))
def start_client():
@@ -147,7 +147,7 @@ def process_chrc(chrc_path):
global hr_ctrl_pt_chrc
hr_ctrl_pt_chrc = (chrc, chrc_props)
else:
- print('Unrecognized characteristic: ' + uuid)
+ print(('Unrecognized characteristic: ' + uuid))
return True
@@ -162,7 +162,7 @@ def process_hr_service(service_path, chr
if uuid != HR_SVC_UUID:
return False
- print('Heart Rate Service found: ' + service_path)
+ print(('Heart Rate Service found: ' + service_path))
# Process the characteristics.
for chrc_path in chrc_paths:
@@ -199,14 +199,14 @@ def main():
chrcs = []
# List characteristics found
- for path, interfaces in objects.items():
- if GATT_CHRC_IFACE not in interfaces.keys():
+ for path, interfaces in list(objects.items()):
+ if GATT_CHRC_IFACE not in list(interfaces.keys()):
continue
chrcs.append(path)
# List sevices found
- for path, interfaces in objects.items():
- if GATT_SERVICE_IFACE not in interfaces.keys():
+ for path, interfaces in list(objects.items()):
+ if GATT_SERVICE_IFACE not in list(interfaces.keys()):
continue
chrc_paths = [d for d in chrcs if d.startswith(path + "/")]
Index: bluez-5.65/test/example-gatt-server
===================================================================
--- bluez-5.65.orig/test/example-gatt-server
+++ bluez-5.65/test/example-gatt-server
@@ -293,7 +293,7 @@ class HeartRateMeasurementChrc(Character
min(0xffff, self.service.energy_expended + 1)
self.hr_ee_count += 1
- print('Updating value: ' + repr(value))
+ print(('Updating value: ' + repr(value)))
self.PropertiesChanged(GATT_CHRC_IFACE, { 'Value': value }, [])
@@ -355,7 +355,7 @@ class HeartRateControlPointChrc(Characte
raise InvalidValueLengthException()
byte = value[0]
- print('Control Point value: ' + repr(byte))
+ print(('Control Point value: ' + repr(byte)))
if byte != 1:
raise FailedException("0x80")
@@ -408,12 +408,12 @@ class BatteryLevelCharacteristic(Charact
self.battery_lvl -= 2
if self.battery_lvl < 0:
self.battery_lvl = 0
- print('Battery Level drained: ' + repr(self.battery_lvl))
+ print(('Battery Level drained: ' + repr(self.battery_lvl)))
self.notify_battery_level()
return True
def ReadValue(self, options):
- print('Battery Level read: ' + repr(self.battery_lvl))
+ print(('Battery Level read: ' + repr(self.battery_lvl)))
return [dbus.Byte(self.battery_lvl)]
def StartNotify(self):
@@ -466,11 +466,11 @@ class TestCharacteristic(Characteristic)
CharacteristicUserDescriptionDescriptor(bus, 1, self))
def ReadValue(self, options):
- print('TestCharacteristic Read: ' + repr(self.value))
+ print(('TestCharacteristic Read: ' + repr(self.value)))
return self.value
def WriteValue(self, value, options):
- print('TestCharacteristic Write: ' + repr(value))
+ print(('TestCharacteristic Write: ' + repr(value)))
self.value = value
@@ -538,11 +538,11 @@ class TestEncryptCharacteristic(Characte
CharacteristicUserDescriptionDescriptor(bus, 3, self))
def ReadValue(self, options):
- print('TestEncryptCharacteristic Read: ' + repr(self.value))
+ print(('TestEncryptCharacteristic Read: ' + repr(self.value)))
return self.value
def WriteValue(self, value, options):
- print('TestEncryptCharacteristic Write: ' + repr(value))
+ print(('TestEncryptCharacteristic Write: ' + repr(value)))
self.value = value
class TestEncryptDescriptor(Descriptor):
@@ -584,11 +584,11 @@ class TestSecureCharacteristic(Character
CharacteristicUserDescriptionDescriptor(bus, 3, self))
def ReadValue(self, options):
- print('TestSecureCharacteristic Read: ' + repr(self.value))
+ print(('TestSecureCharacteristic Read: ' + repr(self.value)))
return self.value
def WriteValue(self, value, options):
- print('TestSecureCharacteristic Write: ' + repr(value))
+ print(('TestSecureCharacteristic Write: ' + repr(value)))
self.value = value
@@ -616,7 +616,7 @@ def register_app_cb():
def register_app_error_cb(error):
- print('Failed to register application: ' + str(error))
+ print(('Failed to register application: ' + str(error)))
mainloop.quit()
@@ -625,8 +625,8 @@ def find_adapter(bus):
DBUS_OM_IFACE)
objects = remote_om.GetManagedObjects()
- for o, props in objects.items():
- if GATT_MANAGER_IFACE in props.keys():
+ for o, props in list(objects.items()):
+ if GATT_MANAGER_IFACE in list(props.keys()):
return o
return None
Index: bluez-5.65/test/list-devices
===================================================================
--- bluez-5.65.orig/test/list-devices
+++ bluez-5.65/test/list-devices
@@ -33,16 +33,16 @@ def extract_uuids(uuid_list):
objects = manager.GetManagedObjects()
all_devices = (str(path) for path, interfaces in objects.items() if
- "org.bluez.Device1" in interfaces.keys())
+ "org.bluez.Device1" in list(interfaces.keys()))
for path, interfaces in objects.items():
- if "org.bluez.Adapter1" not in interfaces.keys():
+ if "org.bluez.Adapter1" not in list(interfaces.keys()):
continue
print("[ " + path + " ]")
properties = interfaces["org.bluez.Adapter1"]
- for key in properties.keys():
+ for key in list(properties.keys()):
value = properties[key]
if (key == "UUIDs"):
list = extract_uuids(value)
@@ -58,7 +58,7 @@ for path, interfaces in objects.items():
dev = objects[dev_path]
properties = dev["org.bluez.Device1"]
- for key in properties.keys():
+ for key in list(properties.keys()):
value = properties[key]
if (key == "UUIDs"):
list = extract_uuids(value)
Index: bluez-5.65/test/pbap-client
===================================================================
--- bluez-5.65.orig/test/pbap-client
+++ bluez-5.65/test/pbap-client
@@ -135,11 +135,11 @@ if __name__ == '__main__':
print(header)
for line in lines:
print(line),
- print
+ print()
def test_paths(paths):
if len(paths) == 0:
- print
+ print()
print("FINISHED")
mainloop.quit()
return
Index: bluez-5.65/test/sap_client.py
===================================================================
--- bluez-5.65.orig/test/sap_client.py
+++ bluez-5.65/test/sap_client.py
@@ -165,7 +165,7 @@ class SAPParam_ConnectionStatus(SAPParam
def __validate(self):
if self.value is not None and self.value not in (0x00, 0x01, 0x02, 0x03, 0x04):
- print "Warning. ConnectionStatus value in reserved range (0x%x)" % self.value
+ print("Warning. ConnectionStatus value in reserved range (0x%x)" % self.value)
def deserialize(self, buf):
ret = SAPParam.deserialize(self, buf)
@@ -183,7 +183,7 @@ class SAPParam_ResultCode(SAPParam):
def __validate(self):
if self.value is not None and self.value not in (0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07):
- print "Warning. ResultCode value in reserved range (0x%x)" % self.value
+ print("Warning. ResultCode value in reserved range (0x%x)" % self.value)
def deserialize(self, buf):
ret = SAPParam.deserialize(self, buf)
@@ -201,7 +201,7 @@ class SAPParam_DisconnectionType(SAPPara
def __validate(self):
if self.value is not None and self.value not in (0x00, 0x01):
- print "Warning. DisconnectionType value in reserved range (0x%x)" % self.value
+ print("Warning. DisconnectionType value in reserved range (0x%x)" % self.value)
def deserialize(self, buf):
ret = SAPParam.deserialize(self, buf)
@@ -227,7 +227,7 @@ class SAPParam_StatusChange(SAPParam):
def __validate(self):
if self.value is not None and self.value not in (0x00, 0x01, 0x02, 0x03, 0x04, 0x05):
- print "Warning. StatusChange value in reserved range (0x%x)" % self.value
+ print("Warning. StatusChange value in reserved range (0x%x)" % self.value)
def deserialize(self, buf):
ret = SAPParam.deserialize(self, buf)
@@ -245,7 +245,7 @@ class SAPParam_TransportProtocol(SAPPara
def __validate(self):
if self.value is not None and self.value not in (0x00, 0x01):
- print "Warning. TransportProtoco value in reserved range (0x%x)" % self.value
+ print("Warning. TransportProtoco value in reserved range (0x%x)" % self.value)
def deserialize(self, buf):
ret = SAPParam.deserialize(self, buf)
@@ -728,7 +728,7 @@ class SAPClient:
self.port = first_match["port"]
self.host = first_match["host"]
- print "SAP Service found on %s(%s)" % first_match["name"] % self.host
+ print("SAP Service found on %s(%s)" % first_match["name"] % self.host)
def __connectRFCOMM(self):
self.sock=BluetoothSocket( RFCOMM )
@@ -739,19 +739,19 @@ class SAPClient:
def __sendMsg(self, msg):
if isinstance(msg, SAPMessage):
s = msg.serialize()
- print "\tTX: " + msg.getContent()
+ print("\tTX: " + msg.getContent())
return self.sock.send(s.tostring())
def __rcvMsg(self, msg):
if isinstance(msg, SAPMessage):
- print "\tRX Wait: %s(id = 0x%.2x)" % (msg.name, msg.id)
+ print("\tRX Wait: %s(id = 0x%.2x)" % (msg.name, msg.id))
data = self.sock.recv(self.bufsize)
if data:
if msg.deserialize(array('B',data)):
- print "\tRX: len(%d) %s" % (len(data), msg.getContent())
+ print("\tRX: len(%d) %s" % (len(data), msg.getContent()))
return msg
else:
- print "msg: %s" % array('B',data)
+ print("msg: %s" % array('B',data))
raise BluetoothError ("Message deserialization failed.")
else:
raise BluetoothError ("Timeout. No data received.")
@@ -797,8 +797,8 @@ class SAPClient:
return False
else:
return False
- except BluetoothError , e:
- print "Error. " +str(e)
+ except BluetoothError as e:
+ print("Error. " +str(e))
return False
def proc_disconnectByClient(self, timeout=0):
@@ -808,8 +808,8 @@ class SAPClient:
time.sleep(timeout) # let srv to close rfcomm
self.__disconnectRFCOMM()
return True
- except BluetoothError , e:
- print "Error. " +str(e)
+ except BluetoothError as e:
+ print("Error. " +str(e))
return False
def proc_disconnectByServer(self, timeout=0):
@@ -823,8 +823,8 @@ class SAPClient:
return self.proc_disconnectByClient(timeout)
- except BluetoothError , e:
- print "Error. " +str(e)
+ except BluetoothError as e:
+ print("Error. " +str(e))
return False
def proc_transferAPDU(self, apdu = "Sample APDU command"):
@@ -832,8 +832,8 @@ class SAPClient:
self.__sendMsg(SAPMessage_TRANSFER_APDU_REQ(apdu))
params = self.__rcvMsg(SAPMessage_TRANSFER_APDU_RESP()).getParams()
return True
- except BluetoothError , e:
- print "Error. " +str(e)
+ except BluetoothError as e:
+ print("Error. " +str(e))
return False
def proc_transferATR(self):
@@ -841,8 +841,8 @@ class SAPClient:
self.__sendMsg(SAPMessage_TRANSFER_ATR_REQ())
params = self.__rcvMsg(SAPMessage_TRANSFER_ATR_RESP()).getParams()
return True
- except BluetoothError , e:
- print "Error. " +str(e)
+ except BluetoothError as e:
+ print("Error. " +str(e))
return False
def proc_powerSimOff(self):
@@ -850,8 +850,8 @@ class SAPClient:
self.__sendMsg(SAPMessage_POWER_SIM_OFF_REQ())
params = self.__rcvMsg(SAPMessage_POWER_SIM_OFF_RESP()).getParams()
return True
- except BluetoothError , e:
- print "Error. " +str(e)
+ except BluetoothError as e:
+ print("Error. " +str(e))
return False
def proc_powerSimOn(self):
@@ -862,8 +862,8 @@ class SAPClient:
return self.proc_transferATR()
return True
- except BluetoothError , e:
- print "Error. " +str(e)
+ except BluetoothError as e:
+ print("Error. " +str(e))
return False
def proc_resetSim(self):
@@ -874,23 +874,23 @@ class SAPClient:
return self.proc_transferATR()
return True
- except BluetoothError , e:
- print "Error. " +str(e)
+ except BluetoothError as e:
+ print("Error. " +str(e))
return False
def proc_reportStatus(self):
try:
params = self.__rcvMsg(SAPMessage_STATUS_IND()).getParams()
- except BluetoothError , e:
- print "Error. " +str(e)
+ except BluetoothError as e:
+ print("Error. " +str(e))
return False
def proc_transferCardReaderStatus(self):
try:
self.__sendMsg(SAPMessage_TRANSFER_CARD_READER_STATUS_REQ())
params = self.__rcvMsg(SAPMessage_TRANSFER_CARD_READER_STATUS_RESP()).getParams()
- except BluetoothError , e:
- print "Error. " +str(e)
+ except BluetoothError as e:
+ print("Error. " +str(e))
return False
def proc_errorResponse(self):
@@ -899,8 +899,8 @@ class SAPClient:
self.__sendMsg(SAPMessage_CONNECT_REQ())
params = self.__rcvMsg(SAPMessage_ERROR_RESP()).getParams()
- except BluetoothError , e:
- print "Error. " +str(e)
+ except BluetoothError as e:
+ print("Error. " +str(e))
return False
def proc_setTransportProtocol(self, protocol = 0):
@@ -922,8 +922,8 @@ class SAPClient:
else:
return False
- except BluetoothError , e:
- print "Error. " +str(e)
+ except BluetoothError as e:
+ print("Error. " +str(e))
return False
if __name__ == "__main__":
Index: bluez-5.65/test/simple-agent
===================================================================
--- bluez-5.65.orig/test/simple-agent
+++ bluez-5.65/test/simple-agent
@@ -24,9 +24,9 @@ dev_path = None
def ask(prompt):
try:
- return raw_input(prompt)
- except:
return input(prompt)
+ except:
+ return eval(input(prompt))
def set_trusted(path):
props = dbus.Interface(bus.get_object("org.bluez", path),
Index: bluez-5.65/test/simple-player
===================================================================
--- bluez-5.65.orig/test/simple-player
+++ bluez-5.65/test/simple-player
@@ -119,7 +119,7 @@ class InputHandler:
return True
try:
- exec "self.player.%s" % s
+ exec("self.player.%s" % s)
except Exception as e:
print(e)
pass
Index: bluez-5.65/test/test-adapter
===================================================================
--- bluez-5.65.orig/test/test-adapter
+++ bluez-5.65/test/test-adapter
@@ -69,7 +69,7 @@ if (args[0] == "list"):
props = interfaces["org.bluez.Adapter1"]
- for (key, value) in props.items():
+ for (key, value) in list(props.items()):
if (key == "Class"):
print(" %s = 0x%06x" % (key, value))
else:
Index: bluez-5.65/test/test-discovery
===================================================================
--- bluez-5.65.orig/test/test-discovery
+++ bluez-5.65/test/test-discovery
@@ -39,10 +39,10 @@ def print_compact(address, properties):
def print_normal(address, properties):
print("[ " + address + " ]")
- for key in properties.keys():
+ for key in list(properties.keys()):
value = properties[key]
if type(value) is dbus.String:
- value = unicode(value).encode('ascii', 'replace')
+ value = str(value).encode('ascii', 'replace')
if (key == "Class"):
print(" %s = 0x%06x" % (key, value))
else:
@@ -71,7 +71,7 @@ def interfaces_added(path, interfaces):
if compact and skip_dev(dev, properties):
return
- devices[path] = dict(devices[path].items() + properties.items())
+ devices[path] = dict(list(devices[path].items()) + list(properties.items()))
else:
devices[path] = properties
@@ -94,7 +94,7 @@ def properties_changed(interface, change
if compact and skip_dev(dev, changed):
return
- devices[path] = dict(devices[path].items() + changed.items())
+ devices[path] = dict(list(devices[path].items()) + list(changed.items()))
else:
devices[path] = changed
Index: bluez-5.65/test/test-hfp
===================================================================
--- bluez-5.65.orig/test/test-hfp
+++ bluez-5.65/test/test-hfp
@@ -186,7 +186,7 @@ class HfpProfile(dbus.service.Object):
version = 0x0105
features = 0
print("NewConnection(%s, %d)" % (path, fd))
- for key in properties.keys():
+ for key in list(properties.keys()):
if key == "Version":
version = properties[key]
elif key == "Features":
Index: bluez-5.65/test/test-profile
===================================================================
--- bluez-5.65.orig/test/test-profile
+++ bluez-5.65/test/test-profile
@@ -34,7 +34,7 @@ class Profile(dbus.service.Object):
def NewConnection(self, path, fd, properties):
self.fd = fd.take()
print("NewConnection(%s, %d)" % (path, self.fd))
- for key in properties.keys():
+ for key in list(properties.keys()):
if key == "Version" or key == "Features":
print(" %s = 0x%04x" % (key, properties[key]))
else:
Index: bluez-5.65/test/map-client
===================================================================
--- bluez-5.65.orig/test/map-client
+++ bluez-5.65/test/map-client
@@ -27,7 +27,7 @@ def unwrap(x):
printed. Taken from d-feet """
if isinstance(x, list):
- return map(unwrap, x)
+ return list(map(unwrap, x))
if isinstance(x, tuple):
return tuple(map(unwrap, x))
@@ -35,7 +35,7 @@ def unwrap(x):
if isinstance(x, dict):
return dict([(unwrap(k), unwrap(v)) for k, v in x.items()])
- for t in [unicode, str, long, int, float, bool]:
+ for t in [str, str, int, int, float, bool]:
if isinstance(x, t):
return t(x)