rd-usb: first working version

This commit is contained in:
Anton Bolshakov 2024-06-06 15:47:03 +08:00
parent 5268ebbb03
commit 58a10f37e3
No known key found for this signature in database
GPG key ID: 32BDCED870788F04
14 changed files with 1051 additions and 14 deletions

View file

@ -1 +1,2 @@
DIST pendulum-2.1.2.tar.gz 81167 BLAKE2B 012e4a4b03711f144222e782ea0d65c1c9ac2863f169077521000fc92b1c024dc23cfab8b11d0b0c2fe8b7c73af3455b97380d2a48a1bb930f1f99e39dab161d SHA512 3e34fd5527bbdfb89b5a27af70f95f293822cdfe87500a3f7ac48084360e537cf160f3642f27d449d9dc1188f42044658c884146129f6a6945bb96ceedde3125
DIST pendulum-3.0.0.tar.gz 84524 BLAKE2B bdd8a4ce35f60de5afdaf5aa1f09f111a75cdf67fbaf393abd1db64ab5bd170da17a209f02de04e32d47dd8b706392c6a2320ea192a8b5bfc91c1cb9813f1f89 SHA512 77ee4f0cb2e36af1471a8ec641dae70bc92fe656bc0cfa2f7b9fe0807a3936273d933d94c7c578e84a3c24bcb97850b8329e25eca1b3ff3c82761197520d468a

View file

@ -3,7 +3,8 @@
EAPI=8
DISTUTILS_USE_PEP517=setuptools
DISTUTILS_EXT=1
DISTUTILS_USE_PEP517=poetry
PYTHON_COMPAT=( python3_{10..12} )
inherit distutils-r1 pypi

View file

@ -0,0 +1,28 @@
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
DISTUTILS_EXT=1
DISTUTILS_USE_PEP517=maturin
PYTHON_COMPAT=( python3_{10..12} )
inherit distutils-r1 pypi
DESCRIPTION="Python datetimes made easy."
HOMEPAGE="https://pendulum.eustace.io/"
LICENSE="MIT"
SLOT="0"
#fixe GO deps
#KEYWORDS="amd64 ~arm64 ~x86"
RDEPEND="
>=dev-python/python-dateutil-2.6[${PYTHON_USEDEP}]
>=dev-python/pytzdata-2020.1[${PYTHON_USEDEP}]
"
DEPEND="${RDEPEND}"
REQUIRED_USE="${PYTHON_REQUIRED_USE}"
RESTRICT="test"
#distutils_enable_tests pytest

View file

@ -0,0 +1 @@
DIST PyBluez-0.22.zip 109060 BLAKE2B 0bbe0d23b3baf0e76567f2dee8f38ca1460767179df15b52c545e84cd131d23a5ae3752dd7867aae6307fd98f0b2c5a5f55b23c550805e163675526696f559fb SHA512 c166a976d311eba73516aaf86ab42b100a39ebccd3d70f93ccb89f59c12127a857698dcfe4b25f8f689eee12187b5f35ccc8235e36cf012e73df155ba5adfae6

View file

@ -0,0 +1,440 @@
diff --git a/bluez/btmodule.c b/bluez/btmodule.c
index 5bfd2ac..18a2db8 100644
--- a/bluez/btmodule.c
+++ b/bluez/btmodule.c
@@ -20,6 +20,7 @@ Local naming conventions:
#include "btmodule.h"
#include <stdio.h>
+#include "pythoncapi_compat.h"
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
@@ -548,7 +549,7 @@ sock_settimeout(PySocketSockObject *s, PyObject *arg)
{
double timeout;
- if (arg == Py_None)
+ if (Py_IsNone(arg))
timeout = -1.0;
else {
timeout = PyFloat_AsDouble(arg);
@@ -1635,7 +1636,7 @@ bt_btohl(PyObject *self, PyObject *args)
else
return PyErr_Format(PyExc_TypeError,
"expected int/long, %s found",
- arg->ob_type->tp_name);
+ Py_TYPE(arg)->tp_name);
if (x == (unsigned long) -1 && PyErr_Occurred())
return NULL;
return PyInt_FromLong(btohl(x));
@@ -1699,7 +1700,7 @@ bt_htobl(PyObject *self, PyObject *args)
else
return PyErr_Format(PyExc_TypeError,
"expected int/long, %s found",
- arg->ob_type->tp_name);
+ Py_TYPE(arg)->tp_name);
return PyInt_FromLong(htobl(x));
}
@@ -1775,7 +1776,7 @@ bt_setdefaulttimeout(PyObject *self, PyObject *arg)
{
double timeout;
- if (arg == Py_None)
+ if (Py_IsNone(arg))
timeout = -1.0;
else {
timeout = PyFloat_AsDouble(arg);
@@ -2800,8 +2801,8 @@ See the bluetooth module for documentation.");
PyMODINIT_FUNC
init_bluetooth(void)
{
- Py_TYPE(&sock_type) = &PyType_Type;
- Py_TYPE(&sdp_session_type) = &PyType_Type;
+ Py_SET_TYPE(&sock_type, &PyType_Type);
+ Py_SET_TYPE(&sdp_session_type, &PyType_Type);
// Initialization steps for _bluetooth.
PyObject *m = Py_InitModule3("_bluetooth",
@@ -2834,8 +2835,8 @@ init_bluetooth(void)
PyMODINIT_FUNC
PyInit__bluetooth(void)
{
- Py_TYPE(&sock_type) = &PyType_Type;
- Py_TYPE(&sdp_session_type) = &PyType_Type;
+ Py_SET_TYPE(&sock_type, &PyType_Type);
+ Py_SET_TYPE(&sdp_session_type, &PyType_Type);
// Initialization steps for _bluetooth.
static struct PyModuleDef moduledef = {
diff --git a/bluez/pythoncapi_compat.h b/bluez/pythoncapi_compat.h
new file mode 100644
index 0000000..e660b61
--- /dev/null
+++ b/bluez/pythoncapi_compat.h
@@ -0,0 +1,364 @@
+// Header file providing new functions of the Python C API to old Python
+// versions.
+//
+// File distributed under the MIT license.
+// Copyright Contributors to the pythoncapi_compat project.
+//
+// Homepage:
+// https://github.com/pythoncapi/pythoncapi_compat
+//
+// Latest version:
+// https://raw.githubusercontent.com/pythoncapi/pythoncapi_compat/master/pythoncapi_compat.h
+//
+// SPDX-License-Identifier: MIT
+
+#ifndef PYTHONCAPI_COMPAT
+#define PYTHONCAPI_COMPAT
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <Python.h>
+#include "frameobject.h" // PyFrameObject, PyFrame_GetBack()
+
+
+// Compatibility with Visual Studio 2013 and older which don't support
+// the inline keyword in C (only in C++): use __inline instead.
+#if (defined(_MSC_VER) && _MSC_VER < 1900 \
+ && !defined(__cplusplus) && !defined(inline))
+# define inline __inline
+# define PYTHONCAPI_COMPAT_MSC_INLINE
+ // These two macros are undefined at the end of this file
+#endif
+
+
+// Cast argument to PyObject* type.
+#ifndef _PyObject_CAST
+# define _PyObject_CAST(op) ((PyObject*)(op))
+#endif
+#ifndef _PyObject_CAST_CONST
+# define _PyObject_CAST_CONST(op) ((const PyObject*)(op))
+#endif
+
+
+// bpo-42262 added Py_NewRef() to Python 3.10.0a3
+#if PY_VERSION_HEX < 0x030A00A3 && !defined(Py_NewRef)
+static inline PyObject* _Py_NewRef(PyObject *obj)
+{
+ Py_INCREF(obj);
+ return obj;
+}
+#define Py_NewRef(obj) _Py_NewRef(_PyObject_CAST(obj))
+#endif
+
+
+// bpo-42262 added Py_XNewRef() to Python 3.10.0a3
+#if PY_VERSION_HEX < 0x030A00A3 && !defined(Py_XNewRef)
+static inline PyObject* _Py_XNewRef(PyObject *obj)
+{
+ Py_XINCREF(obj);
+ return obj;
+}
+#define Py_XNewRef(obj) _Py_XNewRef(_PyObject_CAST(obj))
+#endif
+
+
+// See https://bugs.python.org/issue42522
+#if !defined(_Py_StealRef)
+static inline PyObject* __Py_StealRef(PyObject *obj)
+{
+ Py_DECREF(obj);
+ return obj;
+}
+#define _Py_StealRef(obj) __Py_StealRef(_PyObject_CAST(obj))
+#endif
+
+
+// See https://bugs.python.org/issue42522
+#if !defined(_Py_XStealRef)
+static inline PyObject* __Py_XStealRef(PyObject *obj)
+{
+ Py_XDECREF(obj);
+ return obj;
+}
+#define _Py_XStealRef(obj) __Py_XStealRef(_PyObject_CAST(obj))
+#endif
+
+
+// bpo-39573 added Py_SET_REFCNT() to Python 3.9.0a4
+#if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_REFCNT)
+static inline void _Py_SET_REFCNT(PyObject *ob, Py_ssize_t refcnt)
+{
+ ob->ob_refcnt = refcnt;
+}
+#define Py_SET_REFCNT(ob, refcnt) _Py_SET_REFCNT(_PyObject_CAST(ob), refcnt)
+#endif
+
+
+// Py_SETREF() and Py_XSETREF() were added to Python 3.5.2.
+// It is excluded from the limited C API.
+#if (PY_VERSION_HEX < 0x03050200 && !defined(Py_SETREF)) && !defined(Py_LIMITED_API)
+#define Py_SETREF(op, op2) \
+ do { \
+ PyObject *_py_tmp = _PyObject_CAST(op); \
+ (op) = (op2); \
+ Py_DECREF(_py_tmp); \
+ } while (0)
+
+#define Py_XSETREF(op, op2) \
+ do { \
+ PyObject *_py_tmp = _PyObject_CAST(op); \
+ (op) = (op2); \
+ Py_XDECREF(_py_tmp); \
+ } while (0)
+#endif
+
+
+// bpo-43753 added Py_Is(), Py_IsNone(), Py_IsTrue() and Py_IsFalse()
+// to Python 3.10.0b1.
+#if PY_VERSION_HEX < 0x030A00B1 && !defined(Py_Is)
+# define Py_Is(x, y) ((x) == (y))
+#endif
+#if PY_VERSION_HEX < 0x030A00B1 && !defined(Py_IsNone)
+# define Py_IsNone(x) Py_Is(x, Py_None)
+#endif
+#if PY_VERSION_HEX < 0x030A00B1 && !defined(Py_IsTrue)
+# define Py_IsTrue(x) Py_Is(x, Py_True)
+#endif
+#if PY_VERSION_HEX < 0x030A00B1 && !defined(Py_IsFalse)
+# define Py_IsFalse(x) Py_Is(x, Py_False)
+#endif
+
+
+// bpo-39573 added Py_SET_TYPE() to Python 3.9.0a4
+#if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_TYPE)
+static inline void
+_Py_SET_TYPE(PyObject *ob, PyTypeObject *type)
+{
+ ob->ob_type = type;
+}
+#define Py_SET_TYPE(ob, type) _Py_SET_TYPE(_PyObject_CAST(ob), type)
+#endif
+
+
+// bpo-39573 added Py_SET_SIZE() to Python 3.9.0a4
+#if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_SIZE)
+static inline void
+_Py_SET_SIZE(PyVarObject *ob, Py_ssize_t size)
+{
+ ob->ob_size = size;
+}
+#define Py_SET_SIZE(ob, size) _Py_SET_SIZE((PyVarObject*)(ob), size)
+#endif
+
+
+// bpo-40421 added PyFrame_GetCode() to Python 3.9.0b1
+#if PY_VERSION_HEX < 0x030900B1
+static inline PyCodeObject*
+PyFrame_GetCode(PyFrameObject *frame)
+{
+ assert(frame != NULL);
+ assert(frame->f_code != NULL);
+ return (PyCodeObject*)Py_NewRef(frame->f_code);
+}
+#endif
+
+static inline PyCodeObject*
+_PyFrame_GetCodeBorrow(PyFrameObject *frame)
+{
+ return (PyCodeObject *)_Py_StealRef(PyFrame_GetCode(frame));
+}
+
+
+// bpo-40421 added PyFrame_GetCode() to Python 3.9.0b1
+#if PY_VERSION_HEX < 0x030900B1 && !defined(PYPY_VERSION)
+static inline PyFrameObject*
+PyFrame_GetBack(PyFrameObject *frame)
+{
+ assert(frame != NULL);
+ return (PyFrameObject*)Py_XNewRef(frame->f_back);
+}
+#endif
+
+#if !defined(PYPY_VERSION)
+static inline PyFrameObject*
+_PyFrame_GetBackBorrow(PyFrameObject *frame)
+{
+ return (PyFrameObject *)_Py_XStealRef(PyFrame_GetBack(frame));
+}
+#endif
+
+
+// bpo-39947 added PyThreadState_GetInterpreter() to Python 3.9.0a5
+#if PY_VERSION_HEX < 0x030900A5
+static inline PyInterpreterState *
+PyThreadState_GetInterpreter(PyThreadState *tstate)
+{
+ assert(tstate != NULL);
+ return tstate->interp;
+}
+#endif
+
+
+// bpo-40429 added PyThreadState_GetFrame() to Python 3.9.0b1
+#if PY_VERSION_HEX < 0x030900B1 && !defined(PYPY_VERSION)
+static inline PyFrameObject*
+PyThreadState_GetFrame(PyThreadState *tstate)
+{
+ assert(tstate != NULL);
+ return (PyFrameObject *)Py_XNewRef(tstate->frame);
+}
+#endif
+
+#if !defined(PYPY_VERSION)
+static inline PyFrameObject*
+_PyThreadState_GetFrameBorrow(PyThreadState *tstate)
+{
+ return (PyFrameObject *)_Py_XStealRef(PyThreadState_GetFrame(tstate));
+}
+#endif
+
+
+// bpo-39947 added PyInterpreterState_Get() to Python 3.9.0a5
+#if PY_VERSION_HEX < 0x030900A5
+static inline PyInterpreterState *
+PyInterpreterState_Get(void)
+{
+ PyThreadState *tstate;
+ PyInterpreterState *interp;
+
+ tstate = PyThreadState_GET();
+ if (tstate == NULL) {
+ Py_FatalError("GIL released (tstate is NULL)");
+ }
+ interp = tstate->interp;
+ if (interp == NULL) {
+ Py_FatalError("no current interpreter");
+ }
+ return interp;
+}
+#endif
+
+
+// bpo-39947 added PyInterpreterState_Get() to Python 3.9.0a6
+#if 0x030700A1 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x030900A6 && !defined(PYPY_VERSION)
+static inline uint64_t
+PyThreadState_GetID(PyThreadState *tstate)
+{
+ assert(tstate != NULL);
+ return tstate->id;
+}
+#endif
+
+
+// bpo-37194 added PyObject_CallNoArgs() to Python 3.9.0a1
+#if PY_VERSION_HEX < 0x030900A1
+static inline PyObject*
+PyObject_CallNoArgs(PyObject *func)
+{
+ return PyObject_CallFunctionObjArgs(func, NULL);
+}
+#endif
+
+
+// bpo-39245 made PyObject_CallOneArg() public (previously called
+// _PyObject_CallOneArg) in Python 3.9.0a4
+#if PY_VERSION_HEX < 0x030900A4
+static inline PyObject*
+PyObject_CallOneArg(PyObject *func, PyObject *arg)
+{
+ return PyObject_CallFunctionObjArgs(func, arg, NULL);
+}
+#endif
+
+
+// bpo-1635741 added PyModule_AddObjectRef() to Python 3.10.0a3
+#if PY_VERSION_HEX < 0x030A00A3
+static inline int
+PyModule_AddObjectRef(PyObject *module, const char *name, PyObject *value)
+{
+ Py_XINCREF(value);
+ int res = PyModule_AddObject(module, name, value);
+ if (res < 0) {
+ Py_XDECREF(value);
+ }
+ return res;
+}
+#endif
+
+
+// bpo-40024 added PyModule_AddType() to Python 3.9.0a5
+#if PY_VERSION_HEX < 0x030900A5
+static inline int
+PyModule_AddType(PyObject *module, PyTypeObject *type)
+{
+ const char *name, *dot;
+
+ if (PyType_Ready(type) < 0) {
+ return -1;
+ }
+
+ // inline _PyType_Name()
+ name = type->tp_name;
+ assert(name != NULL);
+ dot = strrchr(name, '.');
+ if (dot != NULL) {
+ name = dot + 1;
+ }
+
+ return PyModule_AddObjectRef(module, name, (PyObject *)type);
+}
+#endif
+
+
+// bpo-40241 added PyObject_GC_IsTracked() to Python 3.9.0a6.
+// bpo-4688 added _PyObject_GC_IS_TRACKED() to Python 2.7.0a2.
+#if PY_VERSION_HEX < 0x030900A6 && !defined(PYPY_VERSION)
+static inline int
+PyObject_GC_IsTracked(PyObject* obj)
+{
+ return (PyObject_IS_GC(obj) && _PyObject_GC_IS_TRACKED(obj));
+}
+#endif
+
+// bpo-40241 added PyObject_GC_IsFinalized() to Python 3.9.0a6.
+// bpo-18112 added _PyGCHead_FINALIZED() to Python 3.4.0 final.
+#if PY_VERSION_HEX < 0x030900A6 && PY_VERSION_HEX >= 0x030400F0 && !defined(PYPY_VERSION)
+static inline int
+PyObject_GC_IsFinalized(PyObject *obj)
+{
+ return (PyObject_IS_GC(obj) && _PyGCHead_FINALIZED((PyGC_Head *)(obj)-1));
+}
+#endif
+
+
+// bpo-39573 added Py_IS_TYPE() to Python 3.9.0a4
+#if PY_VERSION_HEX < 0x030900A4 && !defined(Py_IS_TYPE)
+static inline int
+_Py_IS_TYPE(const PyObject *ob, const PyTypeObject *type) {
+ return ob->ob_type == type;
+}
+#define Py_IS_TYPE(ob, type) _Py_IS_TYPE(_PyObject_CAST_CONST(ob), type)
+#endif
+
+
+// Py_UNUSED() was added to Python 3.4.0b2.
+#if PY_VERSION_HEX < 0x030400B2 && !defined(Py_UNUSED)
+# if defined(__GNUC__) || defined(__clang__)
+# define Py_UNUSED(name) _unused_ ## name __attribute__((unused))
+# else
+# define Py_UNUSED(name) _unused_ ## name
+# endif
+#endif
+
+
+#ifdef PYTHONCAPI_COMPAT_MSC_INLINE
+# undef inline
+# undef PYTHONCAPI_COMPAT_MSC_INLINE
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif // PYTHONCAPI_COMPAT

View file

@ -0,0 +1,423 @@
diff --git a/bluetooth/bluez.py b/bluetooth/bluez.py
index 3faafac..873630f 100644
--- a/bluetooth/bluez.py
+++ b/bluetooth/bluez.py
@@ -151,9 +151,9 @@ def set_l2cap_mtu (sock, mtu):
def _get_available_ports(protocol):
if protocol == RFCOMM:
- return range (1, 31)
+ return list(range(1, 31))
elif protocol == L2CAP:
- return range (0x1001, 0x8000, 2)
+ return list(range(0x1001, 0x8000, 2))
else:
return [0]
diff --git a/examples/advanced/inquiry-with-rssi.py b/examples/advanced/inquiry-with-rssi.py
index 3f41ad7..ae95551 100644
--- a/examples/advanced/inquiry-with-rssi.py
+++ b/examples/advanced/inquiry-with-rssi.py
@@ -96,7 +96,7 @@ def device_inquiry_with_with_rssi(sock):
while True:
pkt = sock.recv(255)
ptype, event, plen = struct.unpack("BBB", pkt[:3])
- print("Event: {}".format(event))
+ print(("Event: {}".format(event)))
if event == bluez.EVT_INQUIRY_RESULT_WITH_RSSI:
pkt = pkt[3:]
nrsp = bluetooth.get_byte(pkt[0])
@@ -105,7 +105,7 @@ def device_inquiry_with_with_rssi(sock):
rssi = bluetooth.byte_to_signed_int(
bluetooth.get_byte(pkt[1 + 13 * nrsp + i]))
results.append((addr, rssi))
- print("[{}] RSSI: {}".format(addr, rssi))
+ print(("[{}] RSSI: {}".format(addr, rssi)))
elif event == bluez.EVT_INQUIRY_COMPLETE:
break
elif event == bluez.EVT_CMD_STATUS:
@@ -120,9 +120,9 @@ def device_inquiry_with_with_rssi(sock):
for i in range(nrsp):
addr = bluez.ba2str(pkt[1+6*i:1+6*i+6])
results.append((addr, -1))
- print("[{}] (no RRSI)".format(addr))
+ print(("[{}] (no RRSI)".format(addr)))
else:
- print("Unrecognized packet type 0x{:02x}.".format(ptype))
+ print(("Unrecognized packet type 0x{:02x}.".format(ptype)))
# restore old filter
sock.setsockopt(bluez.SOL_HCI, bluez.HCI_FILTER, old_filter)
@@ -143,7 +143,7 @@ except Exception as e:
print("Are you sure this a bluetooth 1.2 device?")
print(e)
sys.exit(1)
-print("Current inquiry mode is", mode)
+print(("Current inquiry mode is", mode))
if mode != 1:
print("Writing inquiry mode...")
@@ -155,6 +155,6 @@ if mode != 1:
sys.exit(1)
if result:
print("Error while setting inquiry mode")
- print("Result:", result)
+ print(("Result:", result))
device_inquiry_with_with_rssi(sock)
diff --git a/examples/advanced/l2-mtu.py b/examples/advanced/l2-mtu.py
index cd2cec3..6916231 100644
--- a/examples/advanced/l2-mtu.py
+++ b/examples/advanced/l2-mtu.py
@@ -28,7 +28,7 @@ if mode == "server":
while True:
print("Waiting for incoming connection...")
client_sock, address = server_sock.accept()
- print("Accepted connection from", str(address))
+ print(("Accepted connection from", str(address)))
print("Waiting for data...")
total = 0
@@ -39,7 +39,7 @@ if mode == "server":
break
if not data:
break
- print("Received packet of size", len(data))
+ print(("Received packet of size", len(data)))
client_sock.close()
print("Connection closed.")
@@ -51,7 +51,7 @@ else:
bluetooth.set_l2cap_mtu(sock, 65535)
bt_addr = sys.argv[2]
- print("Trying to connect to {}:1001...".format(bt_addr))
+ print(("Trying to connect to {}:1001...".format(bt_addr)))
port = 0x1001
sock.connect((bt_addr, port))
@@ -59,6 +59,6 @@ else:
for i in range(1, 65535, 100):
pkt = "0" * i
sent = sock.send(pkt)
- print("Sent packet of size {} (tried {}).".format(sent, len(pkt)))
+ print(("Sent packet of size {} (tried {}).".format(sent, len(pkt))))
sock.close()
diff --git a/examples/advanced/l2-unreliable-client.py b/examples/advanced/l2-unreliable-client.py
index 7a4b7bf..49aad8a 100644
--- a/examples/advanced/l2-unreliable-client.py
+++ b/examples/advanced/l2-unreliable-client.py
@@ -21,26 +21,26 @@ bt_addr = sys.argv[1]
timeout = int(sys.argv[2])
num_packets = int(sys.argv[3])
-print("Trying to connect to {}:1001...".format(bt_addr))
+print(("Trying to connect to {}:1001...".format(bt_addr)))
port = 0x1001
sock.connect((bt_addr, port))
print("Connected. Adjusting link parameters.")
-print("Current flush timeout is {} ms.".format(
- bluetooth.read_flush_timeout(bt_addr)))
+print(("Current flush timeout is {} ms.".format(
+ bluetooth.read_flush_timeout(bt_addr))))
try:
bluetooth.write_flush_timeout(bt_addr, timeout)
except bluez.error as e:
print("Error setting flush timeout. Are you sure you're superuser?")
print(e)
sys.exit(1)
-print("New flush timeout is {} ms.".format(
- bluetooth.read_flush_timeout(bt_addr)))
+print(("New flush timeout is {} ms.".format(
+ bluetooth.read_flush_timeout(bt_addr))))
totalsent = 0
for i in range(num_packets):
pkt = "0" * 672
totalsent += sock.send(pkt)
-print("Sent {} bytes total.".format(totalsent))
+print(("Sent {} bytes total.".format(totalsent)))
sock.close()
diff --git a/examples/advanced/l2-unreliable-server.py b/examples/advanced/l2-unreliable-server.py
index f4ab101..e8a284d 100644
--- a/examples/advanced/l2-unreliable-server.py
+++ b/examples/advanced/l2-unreliable-server.py
@@ -11,7 +11,7 @@ server_sock.listen(1)
while True:
print("Waiting for incoming connection...")
client_sock, address = server_sock.accept()
- print("Accepted connection from", str(address))
+ print(("Accepted connection from", str(address)))
print("Waiting for data...")
total = 0
@@ -23,7 +23,7 @@ while True:
if not data:
break
total += len(data)
- print("Total byte read:", total)
+ print(("Total byte read:", total))
client_sock.close()
print("Connection closed")
diff --git a/examples/advanced/read-local-bdaddr.py b/examples/advanced/read-local-bdaddr.py
index e5863f0..ea3c1a1 100644
--- a/examples/advanced/read-local-bdaddr.py
+++ b/examples/advanced/read-local-bdaddr.py
@@ -8,4 +8,4 @@ Read the local Bluetooth device address
import bluetooth
if __name__ == "__main__":
- print(bluetooth.read_local_bdaddr())
+ print((bluetooth.read_local_bdaddr()))
diff --git a/examples/advanced/write-inquiry-scan.py b/examples/advanced/write-inquiry-scan.py
index c3e5e3a..ad395fe 100644
--- a/examples/advanced/write-inquiry-scan.py
+++ b/examples/advanced/write-inquiry-scan.py
@@ -79,14 +79,14 @@ except Exception as e:
print("Error reading inquiry scan activity.")
print(e)
sys.exit(1)
-print("Current inquiry scan interval: {} (0x{:02x}) window: {} (0x{:02x})"
- .format(interval, interval, window, window))
+print(("Current inquiry scan interval: {} (0x{:02x}) window: {} (0x{:02x})"
+ .format(interval, interval, window, window)))
if len(sys.argv) == 3:
interval = int(sys.argv[1])
window = int(sys.argv[2])
- print("Target interval: {} window {}".format(interval, window))
+ print(("Target interval: {} window {}".format(interval, window)))
write_inquiry_scan_activity(sock, interval, window)
interval, window = read_inquiry_scan_activity(sock)
- print("Current inquiry scan interval: {} (0x{:02x}) window: {} (0x{:02x})"
- .format(interval, interval, window, window))
+ print(("Current inquiry scan interval: {} (0x{:02x}) window: {} (0x{:02x})"
+ .format(interval, interval, window, window)))
diff --git a/examples/ble/read_name.py b/examples/ble/read_name.py
index f0b17c7..dbae0c8 100644
--- a/examples/ble/read_name.py
+++ b/examples/ble/read_name.py
@@ -6,7 +6,7 @@ Copyright (C) 2014, Oscar Acena <oscaracena@gmail.com>
This software is under the terms of GPLv3 or later.
"""
-from __future__ import print_function # Python 2 compatibility
+ # Python 2 compatibility
import sys
from bluetooth.ble import GATTRequester
diff --git a/examples/ble/scan.py b/examples/ble/scan.py
index f441fb1..57f60b1 100644
--- a/examples/ble/scan.py
+++ b/examples/ble/scan.py
@@ -7,5 +7,5 @@ from bluetooth.ble import DiscoveryService
service = DiscoveryService()
devices = service.discover(2)
-for address, name in devices.items():
- print("Name: {}, address: {}".format(name, address))
+for address, name in list(devices.items()):
+ print(("Name: {}, address: {}".format(name, address)))
diff --git a/examples/simple/asynchronous-inquiry.py b/examples/simple/asynchronous-inquiry.py
index 5705a8e..3aef9db 100644
--- a/examples/simple/asynchronous-inquiry.py
+++ b/examples/simple/asynchronous-inquiry.py
@@ -21,7 +21,7 @@ class MyDiscoverer(bluetooth.DeviceDiscoverer):
self.done = False
def device_discovered(self, address, device_class, rssi, name):
- print("{} - {}".format(address, name))
+ print(("{} - {}".format(address, name)))
# get some information out of the device class and display it.
# voodoo magic specified at:
@@ -35,7 +35,7 @@ class MyDiscoverer(bluetooth.DeviceDiscoverer):
"Imaging")
major_class = (device_class >> 8) & 0xf
if major_class < 7:
- print(" " + major_classes[major_class])
+ print((" " + major_classes[major_class]))
else:
print(" Uncategorized")
@@ -51,8 +51,8 @@ class MyDiscoverer(bluetooth.DeviceDiscoverer):
for bitpos, classname in service_classes:
if device_class & (1 << (bitpos-1)):
- print(" ", classname)
- print(" RSSI:", rssi)
+ print((" ", classname))
+ print((" RSSI:", rssi))
def inquiry_complete(self):
self.done = True
diff --git a/examples/simple/inquiry.py b/examples/simple/inquiry.py
index d44f4e3..e66f187 100644
--- a/examples/simple/inquiry.py
+++ b/examples/simple/inquiry.py
@@ -16,10 +16,10 @@ print("Performing inquiry...")
nearby_devices = bluetooth.discover_devices(duration=8, lookup_names=True,
flush_cache=True, lookup_class=False)
-print("Found {} devices".format(len(nearby_devices)))
+print(("Found {} devices".format(len(nearby_devices))))
for addr, name in nearby_devices:
try:
- print(" {} - {}".format(addr, name))
+ print((" {} - {}".format(addr, name)))
except UnicodeEncodeError:
- print(" {} - {}".format(addr, name.encode("utf-8", "replace")))
+ print((" {} - {}".format(addr, name.encode("utf-8", "replace"))))
diff --git a/examples/simple/l2capclient.py b/examples/simple/l2capclient.py
index 4b873fd..ff190dd 100644
--- a/examples/simple/l2capclient.py
+++ b/examples/simple/l2capclient.py
@@ -26,17 +26,17 @@ if len(sys.argv) < 2:
bt_addr = sys.argv[1]
port = 0x1001
-print("Trying to connect to {} on PSM 0x{}...".format(bt_addr, port))
+print(("Trying to connect to {} on PSM 0x{}...".format(bt_addr, port)))
sock.connect((bt_addr, port))
print("Connected. Type something...")
while True:
- data = input()
+ data = eval(input())
if not data:
break
sock.send(data)
data = sock.recv(1024)
- print("Data received:", str(data))
+ print(("Data received:", str(data)))
sock.close()
diff --git a/examples/simple/l2capserver.py b/examples/simple/l2capserver.py
index 4848d27..08c39dc 100644
--- a/examples/simple/l2capserver.py
+++ b/examples/simple/l2capserver.py
@@ -21,15 +21,15 @@ server_sock.listen(1)
# service_id=uuid, service_classes = [uuid])
client_sock, address = server_sock.accept()
-print("Accepted connection from", address)
+print(("Accepted connection from", address))
data = client_sock.recv(1024)
-print("Data received:", str(data))
+print(("Data received:", str(data)))
while data:
client_sock.send("Echo =>", str(data))
data = client_sock.recv(1024)
- print("Data received:", str(data))
+ print(("Data received:", str(data)))
client_sock.close()
server_sock.close()
diff --git a/examples/simple/rfcomm-client.py b/examples/simple/rfcomm-client.py
index 60a5b4d..1c01002 100644
--- a/examples/simple/rfcomm-client.py
+++ b/examples/simple/rfcomm-client.py
@@ -26,7 +26,7 @@ if len(sys.argv) < 2:
"the SampleServer service...")
else:
addr = sys.argv[1]
- print("Searching for SampleServer on {}...".format(addr))
+ print(("Searching for SampleServer on {}...".format(addr)))
# search for the SampleServer service
uuid = "94f39d29-7d6d-437d-973b-fba39e49d4ee"
@@ -41,7 +41,7 @@ port = first_match["port"]
name = first_match["name"]
host = first_match["host"]
-print("Connecting to \"{}\" on {}".format(name, host))
+print(("Connecting to \"{}\" on {}".format(name, host)))
# Create the client socket
sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
@@ -49,7 +49,7 @@ sock.connect((host, port))
print("Connected. Type something...")
while True:
- data = input()
+ data = eval(input())
if not data:
break
sock.send(data)
diff --git a/examples/simple/rfcomm-server.py b/examples/simple/rfcomm-server.py
index c72ff0e..afb978d 100644
--- a/examples/simple/rfcomm-server.py
+++ b/examples/simple/rfcomm-server.py
@@ -24,17 +24,17 @@ bluetooth.advertise_service(server_sock, "SampleServer", service_id=uuid,
# protocols=[bluetooth.OBEX_UUID]
)
-print("Waiting for connection on RFCOMM channel", port)
+print(("Waiting for connection on RFCOMM channel", port))
client_sock, client_info = server_sock.accept()
-print("Accepted connection from", client_info)
+print(("Accepted connection from", client_info))
try:
while True:
data = client_sock.recv(1024)
if not data:
break
- print("Received", data)
+ print(("Received", data))
except IOError:
pass
diff --git a/examples/simple/sdp-browse.py b/examples/simple/sdp-browse.py
index 45ea1af..350bf3a 100644
--- a/examples/simple/sdp-browse.py
+++ b/examples/simple/sdp-browse.py
@@ -24,17 +24,17 @@ if target == "all":
services = bluetooth.find_service(address=target)
if len(services) > 0:
- print("Found {} services on {}.".format(len(services), sys.argv[1]))
+ print(("Found {} services on {}.".format(len(services), sys.argv[1])))
else:
print("No services found.")
for svc in services:
- print("\nService Name:", svc["name"])
- print(" Host: ", svc["host"])
- print(" Description:", svc["description"])
- print(" Provided By:", svc["provider"])
- print(" Protocol: ", svc["protocol"])
- print(" channel/PSM:", svc["port"])
- print(" svc classes:", svc["service-classes"])
- print(" profiles: ", svc["profiles"])
- print(" service id: ", svc["service-id"])
+ print(("\nService Name:", svc["name"]))
+ print((" Host: ", svc["host"]))
+ print((" Description:", svc["description"]))
+ print((" Provided By:", svc["provider"]))
+ print((" Protocol: ", svc["protocol"]))
+ print((" channel/PSM:", svc["port"]))
+ print((" svc classes:", svc["service-classes"]))
+ print((" profiles: ", svc["profiles"]))
+ print((" service id: ", svc["service-id"]))
diff --git a/setup.py b/setup.py
index d238821..3b5ccd1 100755
--- a/setup.py
+++ b/setup.py
@@ -124,7 +124,6 @@ setup(name='PyBluez',
license='GPL',
extras_require={'ble': ['gattlib==0.20150805']},
package_dir=package_dir,
- use_2to3=True,
install_requires=install_requires,
package_data=package_data,
eager_resources=eager_resources,

View file

@ -0,0 +1,16 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="project">
<email>b@edevau.net</email>
<name>Andreas Billmeier</name>
</maintainer>
<upstream>
<remote-id type="pypi">PyBluez</remote-id>
<remote-id type="github">pybluez/pybluez</remote-id>
<maintainer status="unknown">
<email>ashuang@alum.mit.edu</email>
<name>Piotr Karulis</name>
</maintainer>
</upstream>
</pkgmetadata>

View file

@ -0,0 +1,33 @@
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
PYTHON_COMPAT=( python3_{10..12} )
DISTUTILS_USE_PEP517=setuptools
PYPI_NO_NORMALIZE=1
PYPI_PN="PyBluez"
inherit distutils-r1 pypi
DESCRIPTION="Bluetooth Python extension module"
HOMEPAGE="https://github.com/pybluez/pybluez/ https://pypi.org/project/PyBluez/"
SRC_URI="$(pypi_sdist_url --no-normalize "${PYPI_PN}" "${PV}" ".zip")"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="amd64 arm64 x86"
IUSE="test"
RESTRICT="!test? ( test )"
PATCHES=("${FILESDIR}/${PV}_py311.patch")
RDEPEND="net-wireless/bluez"
BDEPEND="
app-arch/unzip
test? (
dev-python/pytest[${PYTHON_USEDEP}]
)"
python_test() {
py.test -v -v || die
}

View file

@ -9,4 +9,7 @@
<remote-id type="github">r0x0r/pywebview</remote-id>
<remote-id type="pypi">pywebview</remote-id>
</upstream>
<use>
<flag name="pyqt5">Use <pkg>dev-python/PyQt5</pkg> as Qt for Python implementation</flag>
</use>
</pkgmetadata>

View file

@ -14,26 +14,36 @@ HOMEPAGE="https://github.com/r0x0r/pywebview"
LICENSE="BSD"
SLOT="0"
KEYWORDS="amd64 ~arm64 ~x86"
IUSE="gtk +qt5 qt6"
REQUIRED_USE="|| ( gtk qt5 qt6 )"
# copy USE flags from dev-python/QtPy
IUSE="gtk +pyqt5"
REQUIRED_USE="|| ( gtk pyqt5 )"
RDEPEND="
dev-python/bottle
dev-python/cryptography
dev-python/proxy_tools
dev-python/proxy_tools[${PYTHON_USEDEP}]
dev-python/bottle[${PYTHON_USEDEP}]
dev-python/typing-extensions[${PYTHON_USEDEP}]
dev-python/cryptography[${PYTHON_USEDEP}]
gtk? (
dev-python/pygobject[cairo,${PYTHON_USEDEP}]
net-libs/webkit-gtk
)
qt5? (
dev-python/pyside2[${PYTHON_USEDEP},webengine]
pyqt5? (
dev-python/QtPy[${PYTHON_USEDEP},webengine]
dev-python/PyQt5[${PYTHON_USEDEP}]
dev-python/PyQtWebEngine[${PYTHON_USEDEP}]
)
qt6? (
dev-python/pyside6[${PYTHON_USEDEP},webengine]
dev-python/QtPy[${PYTHON_USEDEP},webengine]
)
"
"
# qt5? (
# dev-python/pyside2[${PYTHON_USEDEP},webengine]
# dev-python/QtPy[${PYTHON_USEDEP},webengine]
# )
# qt6? (
# dev-python/pyside6[${PYTHON_USEDEP},webengine]
# dev-python/QtPy[${PYTHON_USEDEP},webengine]
# )
#"
distutils_enable_tests pytest

View file

@ -14,6 +14,6 @@ SRC_URI="https://github.com/rr-/screeninfo/archive/refs/tags/${PV}.tar.gz -> ${P
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~x86"
KEYWORDS="amd64 ~arm64 ~x86"
distutils_enable_tests pytest

View file

@ -0,0 +1 @@
DIST rd-usb-1.22.1.gh.tar.gz 2137122 BLAKE2B e393b79fd96f45b1aec9c5b9e2e6a2e635eaf855aa01583a565c165c24f99d8888fc1ec3464a5cf632eb1cd5ba458333a9cdc4edfd45b4f129d54634109b43af SHA512 0bcc848007eae0927c88883789f7ddf75aad488e649da53cd69fef17d8fd0e1b1f645bbb7cb8e5fa80b085beeb7b819d3b9458cc9a652f8302066bd1f4425887

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="person">
<email>unknown@pentoo.ch</email>
<name>Author Unknown</name>
</maintainer>
<upstream>
<remote-id type="github">kolinger/rd-usb</remote-id>
</upstream>
<use>
<flag name="webui">Enable the Web UI</flag>
</use>
</pkgmetadata>

View file

@ -0,0 +1,66 @@
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
PYTHON_COMPAT=( python3_{10..12} )
inherit python-single-r1
DESCRIPTION="Web GUI for RuiDeng/Riden USB testers (UM34C, UM24C, UM25C, TC66C)"
HOMEPAGE="https://github.com/kolinger/rd-usb"
SRC_URI="https://github.com/kolinger/rd-usb/archive/refs/tags/${PV}.tar.gz -> ${P}.gh.tar.gz"
LICENSE="GPL-3"
SLOT="0"
WEBAPP_MANUAL_SLOT="yes"
KEYWORDS="amd64 ~arm64 ~x86"
IUSE="+webui"
RDEPEND="$(python_gen_cond_dep '
dev-python/flask[${PYTHON_USEDEP}]
dev-python/pyserial[${PYTHON_USEDEP}]
dev-python/python-socketio[${PYTHON_USEDEP}]
dev-python/python-engineio[${PYTHON_USEDEP}]
dev-python/appdirs[${PYTHON_USEDEP}]
dev-python/bleak[${PYTHON_USEDEP}]
dev-python/pycryptodome[${PYTHON_USEDEP}]
dev-python/pybluez[${PYTHON_USEDEP}]
<dev-python/pendulum-3.0.0[${PYTHON_USEDEP}]
webui? ( dev-python/pywebview[${PYTHON_USEDEP}]
dev-python/pythonnet[${PYTHON_USEDEP}]
dev-python/screeninfo[${PYTHON_USEDEP}] )
')
${PYTHON_DEPS}
"
DEPEND="${RDEPEND}"
REQUIRED_USE="${PYTHON_REQUIRED_USE}"
RESTRICT="test"
#distutils_enable_tests pytest
INSTALLDIR="/usr/share/${PN}"
#pkg_setup() {
# python-single-r1_pkg_setup
#}
src_prepare() {
sed -i -e "1i #!/usr/bin/env python\n" web.py || die
python_fix_shebang web.py
default
}
src_install() {
newbin - ${PN}_web <<-EOF
#!/bin/sh
cd ${INSTALLDIR}
${EPYTHON} ./web.py "\$@"
EOF
insinto "${INSTALLDIR}"
doins -r .
}