diff mbox series

[BlueZ,1/1] test examples: fix python3 errors

Message ID 20240509214231.2783781-2-me@prestonhunt.com
State New
Headers show
Series Update python2 examples to run properly with python3 | expand

Commit Message

Preston Hunt May 9, 2024, 9:42 p.m. UTC
These scripts have "#!/usr/bin/env python3" but have python2 syntax in
several places. Fixed by running the "2to3" utility.
---
 test/exchange-business-cards |  4 +--
 test/get-obex-capabilities   |  6 ++--
 test/list-folders            |  6 ++--
 test/sap_client.py           | 68 ++++++++++++++++++------------------
 test/simple-player           |  4 +--
 5 files changed, 44 insertions(+), 44 deletions(-)

Comments

bluez.test.bot@gmail.com May 9, 2024, 11:41 p.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=852053

---Test result---

Test Summary:
CheckPatch                    PASS      0.54 seconds
GitLint                       PASS      0.27 seconds
BuildEll                      PASS      24.65 seconds
BluezMake                     PASS      1733.09 seconds
MakeCheck                     PASS      13.34 seconds
MakeDistcheck                 PASS      179.31 seconds
CheckValgrind                 PASS      246.76 seconds
CheckSmatch                   PASS      349.98 seconds
bluezmakeextell               PASS      118.94 seconds
IncrementalBuild              PASS      1628.80 seconds
ScanBuild                     PASS      993.90 seconds



---
Regards,
Linux Bluetooth
diff mbox series

Patch

diff --git a/test/exchange-business-cards b/test/exchange-business-cards
index 12d513362..f28d90e30 100755
--- a/test/exchange-business-cards
+++ b/test/exchange-business-cards
@@ -9,10 +9,10 @@  client = dbus.Interface(bus.get_object("org.bluez.obex", "/org/bluez/obex"),
 					"org.bluez.obex.Client")
 
 if (len(sys.argv) < 4):
-	print "Usage: %s <device> <clientfile> <file>" % (sys.argv[0])
+	print("Usage: %s <device> <clientfile> <file>" % (sys.argv[0]))
 	sys.exit(1)
 
-print "Creating Session"
+print("Creating Session")
 path = client.CreateSession(sys.argv[1], { "Target": "OPP" })
 opp = dbus.Interface(bus.get_object("org.bluez.obex", path),
 					"org.bluez.obex.ObjectPush")
diff --git a/test/get-obex-capabilities b/test/get-obex-capabilities
index 25a996e18..c2e5710db 100755
--- a/test/get-obex-capabilities
+++ b/test/get-obex-capabilities
@@ -9,12 +9,12 @@  client = dbus.Interface(bus.get_object("org.bluez.obex", "/org/bluez/obex"),
 					"org.bluez.obex.Client")
 
 if (len(sys.argv) < 3):
-	print "Usage: %s <device> <target>" % (sys.argv[0])
+	print("Usage: %s <device> <target>" % (sys.argv[0]))
 	sys.exit(1)
 
-print "Creating Session"
+print("Creating Session")
 session_path = client.CreateSession(sys.argv[1], { "Target": sys.argv[2] })
 session = dbus.Interface(bus.get_object("org.bluez.obex", session_path),
 					"org.bluez.obex.Session")
 
-print session.GetCapabilities()
+print(session.GetCapabilities())
diff --git a/test/list-folders b/test/list-folders
index 414bb367b..3b080e7ba 100755
--- a/test/list-folders
+++ b/test/list-folders
@@ -22,15 +22,15 @@  def list_folder(folder):
 
 	for i in ftp.ListFolder():
 		if i["Type"] == "folder":
-			print "%s/" % (i["Name"])
+			print("%s/" % (i["Name"]))
 		else:
-			print "%s" % (i["Name"])
+			print("%s" % (i["Name"]))
 
 
 if __name__ == '__main__':
 
 	if len(sys.argv) < 2:
-		print "Usage: %s <device> [folder]" % (sys.argv[0])
+		print("Usage: %s <device> [folder]" % (sys.argv[0]))
 		sys.exit(1)
 
 	folder = None
diff --git a/test/sap_client.py b/test/sap_client.py
index fed13aedc..2da46eee3 100644
--- a/test/sap_client.py
+++ b/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(SAPParam):
 
     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(SAPParam):
 
     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__":
diff --git a/test/simple-player b/test/simple-player
index 190e047e2..8a1cb1e33 100755
--- a/test/simple-player
+++ b/test/simple-player
@@ -1,7 +1,7 @@ 
 #!/usr/bin/env python3
 # SPDX-License-Identifier: LGPL-2.1-or-later
 
-from __future__ import print_function
+
 
 import os
 import sys
@@ -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