From c8f94eda7551555b1b6c8ada2788d5120ed0b32c Mon Sep 17 00:00:00 2001 From: Martin Olejar Date: Mon, 6 Jan 2020 20:39:01 +0100 Subject: [PATCH] Fix setup.py, clean code and update readme --- README.md | 12 ++++++++---- mboot/mcuboot.py | 6 +++--- setup.py | 8 ++++---- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index ac30324..8238295 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,10 @@ In case of development, install it from cloned sources: 2. Specify the `--user` option to install locally into your home directory (export "~/.local/bin" into PATH variable if haven't). 3. Run the command in a [virtualenv](https://virtualenv.pypa.io/en/latest/) local to a specific project working set. +> For running `mboot` module or CLI without root privileges in Linux OS copy following udev rules +[90-imx-sdp.rules](https://github.com/molejar/pyIMX/blob/master/udev/90-imx-sdp.rules) +into `/etc/udev/rules.d` directory and reload it with command: `sudo udevadm control --reload-rules`. + Usage ----- @@ -117,8 +121,8 @@ if devices: print(str(e)) ``` -`mboot` module is implementing also logging functionality for easy debugging of communication interfaces. All what you -need to do is just import `logging` module and set the logging level (`DEBUG` or `INFO`) with following line of code: +`mboot` module is implementing also logging functionality for easy debugging all communication interfaces. To get it +working you need only import `logging` module and set the logging level (`DEBUG` or `INFO`) with following line of code: `logging.basicConfig(level=logging.DEBUG)` ```python @@ -150,8 +154,8 @@ DEBUG:MBOOT:USB:Close Interface [ mboot ] Tool -------------- -pyMBoot is distributed with command-line utility `mboot`, which demonstrate the complete functionality of this library and -can be used as replacement of `blhos` tool. If you write `mboot` into shell and click enter, then you get the description +The `mboot` module is distributed with command-line utility, which demonstrate the complete functionality of this library +and can be used as replacement of `blhos` tool. If you write `mboot` into shell and click enter, then you get the description of its usage. For getting the help of individual commands just use `mboot -?`. ``` bash diff --git a/mboot/mcuboot.py b/mboot/mcuboot.py index 470cba4..7ea9ee6 100644 --- a/mboot/mcuboot.py +++ b/mboot/mcuboot.py @@ -82,7 +82,7 @@ def _check_response(self, cmd_packet: CmdPacket, cmd_response: CmdResponse, logg cmd_name = CommandTag[cmd_packet.header.tag] if not isinstance(cmd_response, CmdResponse): - raise McuBootError(f"CMD: {cmd_name} Error: Unsupported response format") + raise McuBootError(f"CMD: {cmd_name} -> Unsupported response format") self._status_code = cmd_response.status_code @@ -158,7 +158,7 @@ def _read_data(self, cmd_tag: int, length: int, timeout: int = 1000) -> bytes: if len(data) < length or self.status_code != StatusCode.SUCCESS: logger.debug(f"CMD: Received {len(data)} from {length} Bytes, {self.status_info}") if self._cmd_exception: - raise McuBootCommandError(CommandTag[cmd_tag], response.status_code) + raise McuBootCommandError(CommandTag[cmd_tag], self.status_code) else: logger.info(f"CMD: Successfully Received {len(data)} from {length} Bytes") @@ -189,7 +189,7 @@ def _send_data(self, cmd_tag: int, data: bytes) -> bool: logger.debug('RX-PACKET: ' + str(response)) self._status_code = response.status_code if response.status_code != StatusCode.SUCCESS: - logger.debug(f"CMD: Send Error, " + self.status_info) + logger.debug("CMD: Send Error, " + self.status_info) if self._cmd_exception: raise McuBootCommandError(CommandTag[cmd_tag], self.status_code) return False diff --git a/setup.py b/setup.py index 6f7fd4d..b5146e2 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ from os import path -from setuptools import setup +from setuptools import setup, find_packages from mboot import __version__, __license__, __author__, __contact__ @@ -43,15 +43,15 @@ def get_long_description(): 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', - 'Operating System :: POSIX :: Linux', + 'License :: OSI Approved :: BSD License', 'Operating System :: Microsoft :: Windows', + 'Operating System :: POSIX :: Linux', 'Environment :: Console', - 'License :: OSI Approved :: BSD License', 'Topic :: Scientific/Engineering', 'Topic :: Software Development :: Embedded Systems', 'Topic :: Utilities', ], - packages=['mboot'], + packages=find_packages('.'), entry_points={ 'console_scripts': [ 'mboot = mboot.__main__:main',