All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 0/1] Update python2 examples to run properly with python3
@ 2024-05-09 21:42 Preston Hunt
  2024-05-09 21:42 ` [PATCH BlueZ 1/1] test examples: fix python3 errors Preston Hunt
  2024-05-13 14:00 ` [PATCH BlueZ 0/1] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 4+ messages in thread
From: Preston Hunt @ 2024-05-09 21:42 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Preston Hunt

Several of the examples in the test/ directory are python2 scripts. In
commit d31f04aa928ae8fb7a4fc5b0876dd17ea65d4513, added a python3
shebang, causing these scripts to be run by python3. Because they are
python2 scripts, they won't run properly.

Fixed by running Python's 2to3 utility.

Preston Hunt (1):
  test examples: fix python3 errors

 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(-)

-- 
2.42.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH BlueZ 1/1] test examples: fix python3 errors
  2024-05-09 21:42 [PATCH BlueZ 0/1] Update python2 examples to run properly with python3 Preston Hunt
@ 2024-05-09 21:42 ` Preston Hunt
  2024-05-09 23:41   ` Update python2 examples to run properly with python3 bluez.test.bot
  2024-05-13 14:00 ` [PATCH BlueZ 0/1] " patchwork-bot+bluetooth
  1 sibling, 1 reply; 4+ messages in thread
From: Preston Hunt @ 2024-05-09 21:42 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Preston Hunt

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(-)

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
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: Update python2 examples to run properly with python3
  2024-05-09 21:42 ` [PATCH BlueZ 1/1] test examples: fix python3 errors Preston Hunt
@ 2024-05-09 23:41   ` bluez.test.bot
  0 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2024-05-09 23:41 UTC (permalink / raw)
  To: linux-bluetooth, me

[-- Attachment #1: Type: text/plain, Size: 948 bytes --]

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH BlueZ 0/1] Update python2 examples to run properly with python3
  2024-05-09 21:42 [PATCH BlueZ 0/1] Update python2 examples to run properly with python3 Preston Hunt
  2024-05-09 21:42 ` [PATCH BlueZ 1/1] test examples: fix python3 errors Preston Hunt
@ 2024-05-13 14:00 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+bluetooth @ 2024-05-13 14:00 UTC (permalink / raw)
  To: Preston Hunt; +Cc: linux-bluetooth

Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Thu,  9 May 2024 14:42:30 -0700 you wrote:
> Several of the examples in the test/ directory are python2 scripts. In
> commit d31f04aa928ae8fb7a4fc5b0876dd17ea65d4513, added a python3
> shebang, causing these scripts to be run by python3. Because they are
> python2 scripts, they won't run properly.
> 
> Fixed by running Python's 2to3 utility.
> 
> [...]

Here is the summary with links:
  - [BlueZ,1/1] test examples: fix python3 errors
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=832412f5e36a

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-05-13 14:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-09 21:42 [PATCH BlueZ 0/1] Update python2 examples to run properly with python3 Preston Hunt
2024-05-09 21:42 ` [PATCH BlueZ 1/1] test examples: fix python3 errors Preston Hunt
2024-05-09 23:41   ` Update python2 examples to run properly with python3 bluez.test.bot
2024-05-13 14:00 ` [PATCH BlueZ 0/1] " patchwork-bot+bluetooth

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.