Skip to content

Commit 136409c

Browse files
Merge pull request #56 from bridadan/optional_pyocd
Optional pyocd dependency
2 parents ec87a5c + 5ff92dd commit 136409c

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def read(fname):
4646
install_requires=[
4747
"PySerial>=3.0",
4848
"requests",
49-
"pyocd==0.14.0",
5049
"intelhex",
5150
"future",
5251
"PrettyTable>=0.7.2",
@@ -58,5 +57,7 @@ def read(fname):
5857
"colorama>=0.3,<0.5",
5958
],
6059
tests_require=["mock>=2", "pytest>=3"],
61-
extras_require={"colorized_logs": ["colorlog"]},
60+
extras_require={
61+
"pyocd": ["pyocd==0.14.0"]
62+
},
6263
)

src/mbed_os_tools/test/host_tests_plugins/module_copy_pyocd.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@
1515

1616
import os
1717
from .host_test_plugins import HostTestPluginBase
18-
from pyocd.core.helpers import ConnectHelper
19-
from pyocd.flash.loader import FileProgrammer
2018

19+
try:
20+
from pyocd.core.helpers import ConnectHelper
21+
from pyocd.flash.loader import FileProgrammer
22+
PYOCD_PRESENT = True
23+
except ImportError:
24+
PYOCD_PRESENT = False
2125

2226
class HostTestPluginCopyMethod_pyOCD(HostTestPluginBase):
2327
# Plugin interface
@@ -44,6 +48,13 @@ def execute(self, capability, *args, **kwargs):
4448
@param kwargs Additional arguments
4549
@return Capability call return value
4650
"""
51+
if not PYOCD_PRESENT:
52+
self.print_plugin_error(
53+
'The "pyocd" feature is not installed. Please run '
54+
'"pip install mbed-os-tools[pyocd]" to enable the "pyocd" copy plugin.'
55+
)
56+
return False
57+
4758
if not self.check_parameters(capability, *args, **kwargs):
4859
return False
4960

src/mbed_os_tools/test/host_tests_plugins/module_reset_pyocd.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
# limitations under the License.
1515

1616
from .host_test_plugins import HostTestPluginBase
17-
from pyocd.core.helpers import ConnectHelper
17+
18+
try:
19+
from pyocd.core.helpers import ConnectHelper
20+
PYOCD_PRESENT = True
21+
except ImportError:
22+
PYOCD_PRESENT = False
1823

1924

2025
class HostTestPluginResetMethod_pyOCD(HostTestPluginBase):
@@ -48,6 +53,13 @@ def execute(self, capability, *args, **kwargs):
4853
@details Each capability e.g. may directly just call some command line program or execute building pythonic function
4954
@return Capability call return value
5055
"""
56+
if not PYOCD_PRESENT:
57+
self.print_plugin_error(
58+
'The "pyocd" feature is not installed. Please run '
59+
'"pip install mbed-os-tools[pyocd]" to enable the "pyocd" reset plugin.'
60+
)
61+
return False
62+
5163
if not kwargs['target_id']:
5264
self.print_plugin_error("Error: target_id not set")
5365
return False

0 commit comments

Comments
 (0)