upgpkg: wordpress 6.2.1-1
[ArchLinux/community.git] / python-pyocd / trunk / python-pyocd-0.33.1-optional_libusb_package.patch
blob8e77cf69c38cd4cd51ae033b9fbd83e56b1119f8
1 diff --git c/pyocd/probe/picoprobe.py w/pyocd/probe/picoprobe.py
2 index 481e984f..14d1214d 100644
3 --- c/pyocd/probe/picoprobe.py
4 +++ w/pyocd/probe/picoprobe.py
5 @@ -18,8 +18,12 @@
6 from array import array
8 from time import sleep
9 +try:
10 + from libusb_package import find as usb_find
11 +except ImportError:
12 + from usb.core import find as usb_find
14 from usb import core, util
15 -import libusb_package
17 import platform
18 import errno
19 @@ -108,7 +112,7 @@ class PicoLink(object):
20 """@brief Find and return all Picoprobes """
21 try:
22 # Use a custom matcher to make sure the probe is a Picoprobe and accessible.
23 - return [PicoLink(probe) for probe in libusb_package.find(find_all=True, custom_match=FindPicoprobe(uid))]
24 + return [PicoLink(probe) for probe in usb_find(find_all=True, custom_match=FindPicoprobe(uid))]
25 except core.NoBackendError:
26 show_no_libusb_warning()
27 return []
28 diff --git c/pyocd/probe/pydapaccess/interface/pyusb_backend.py w/pyocd/probe/pydapaccess/interface/pyusb_backend.py
29 index cf240043..229fc7c5 100644
30 --- c/pyocd/probe/pydapaccess/interface/pyusb_backend.py
31 +++ w/pyocd/probe/pydapaccess/interface/pyusb_backend.py
32 @@ -37,7 +37,6 @@ TRACE = LOG.getChild("trace")
33 TRACE.setLevel(logging.CRITICAL)
35 try:
36 - import libusb_package
37 import usb.core
38 import usb.util
39 except ImportError:
40 @@ -45,6 +44,12 @@ except ImportError:
41 else:
42 IS_AVAILABLE = True
44 +try:
45 + from libusb_package import find as usb_find
46 +except ImportError:
47 + from usb.core import find as usb_find
50 class PyUSB(Interface):
51 """@brief CMSIS-DAP USB interface class using pyusb for the backend."""
53 @@ -70,7 +75,7 @@ class PyUSB(Interface):
54 assert self.closed is True
56 # Get device handle
57 - dev = libusb_package.find(custom_match=FindDap(self.serial_number))
58 + dev = usb_find(custom_match=FindDap(self.serial_number))
59 if dev is None:
60 raise DAPAccessIntf.DeviceError("Device %s not found" % self.serial_number)
62 @@ -161,7 +166,7 @@ class PyUSB(Interface):
63 """
64 # find all cmsis-dap devices
65 try:
66 - all_devices = libusb_package.find(find_all=True, custom_match=FindDap())
67 + all_devices = usb_find(find_all=True, custom_match=FindDap())
68 except usb.core.NoBackendError:
69 if not PyUSB.did_show_no_libusb_warning:
70 LOG.warning("CMSIS-DAPv1 probes may not be detected because no libusb library was found.")
71 diff --git c/pyocd/probe/pydapaccess/interface/pyusb_v2_backend.py w/pyocd/probe/pydapaccess/interface/pyusb_v2_backend.py
72 index a9b0a1a0..e2007908 100644
73 --- c/pyocd/probe/pydapaccess/interface/pyusb_v2_backend.py
74 +++ w/pyocd/probe/pydapaccess/interface/pyusb_v2_backend.py
75 @@ -38,7 +38,6 @@ TRACE = LOG.getChild("trace")
76 TRACE.setLevel(logging.CRITICAL)
78 try:
79 - import libusb_package
80 import usb.core
81 import usb.util
82 except ImportError:
83 @@ -46,6 +45,12 @@ except ImportError:
84 else:
85 IS_AVAILABLE = True
87 +try:
88 + from libusb_package import find as usb_find
89 +except ImportError:
90 + from usb.core import find as usb_find
93 class PyUSBv2(Interface):
94 """@brief CMSIS-DAPv2 interface using pyUSB."""
96 @@ -84,7 +89,7 @@ class PyUSBv2(Interface):
97 assert self.closed is True
99 # Get device handle
100 - dev = libusb_package.find(custom_match=HasCmsisDapv2Interface(self.serial_number))
101 + dev = usb_find(custom_match=HasCmsisDapv2Interface(self.serial_number))
102 if dev is None:
103 raise DAPAccessIntf.DeviceError("Device %s not found" %
104 self.serial_number)
105 @@ -187,7 +192,7 @@ class PyUSBv2(Interface):
106 """@brief Returns all the connected devices with a CMSIS-DAPv2 interface."""
107 # find all cmsis-dap devices
108 try:
109 - all_devices = libusb_package.find(find_all=True, custom_match=HasCmsisDapv2Interface())
110 + all_devices = usb_find(find_all=True, custom_match=HasCmsisDapv2Interface())
111 except usb.core.NoBackendError:
112 common.show_no_libusb_warning()
113 return []
114 diff --git c/pyocd/probe/stlink/usb.py w/pyocd/probe/stlink/usb.py
115 index c9a400af..883c014c 100644
116 --- c/pyocd/probe/stlink/usb.py
117 +++ w/pyocd/probe/stlink/usb.py
118 @@ -15,7 +15,10 @@
119 # See the License for the specific language governing permissions and
120 # limitations under the License.
122 -import libusb_package
123 +try:
124 + from libusb_package import find as usb_find
125 +except ImportError:
126 + from usb.core import find as usb_find
127 import usb.core
128 import usb.util
129 import logging
130 @@ -101,7 +104,7 @@ class STLinkUSBInterface:
131 @classmethod
132 def get_all_connected_devices(cls):
133 try:
134 - devices = libusb_package.find(find_all=True, custom_match=cls._usb_match)
135 + devices = usb_find(find_all=True, custom_match=cls._usb_match)
136 except usb.core.NoBackendError:
137 common.show_no_libusb_warning()
138 return []