Skip to content

Commit

Permalink
Merge pull request #5 from ussserrr/dev
Browse files Browse the repository at this point in the history
v0.95
  • Loading branch information
ussserrr authored Dec 15, 2019
2 parents 46b1515 + cd09222 commit ea51af3
Show file tree
Hide file tree
Showing 8 changed files with 282 additions and 105 deletions.
22 changes: 20 additions & 2 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ stm32pio changelog:
ver. 0.73 (10-11.02.19):
- New: use more convenient Python project structure
- New: package can be install using setuptools
- New: TODO list
- New: TO-DO list
- New: '--directory' option is now optional if the program gets called from the project directory
- Fixed: license copyright
- Fixed: 'dot' path will be handle successfully now
Expand Down Expand Up @@ -100,7 +100,7 @@ stm32pio changelog:
- Changed: actualized .ioc file and clean-up the code according to the latest STM32CubeMX version (5.3.0 at the moment)
- Changed: revised and improved util module

ver. 0.9 (12.19):
ver. 0.9 (11-12.19):
- New: tested with Python3 version of PlatformIO
- New: '__main__.py' file (to run the app as module (python -m stm32pio))
- New: 'init' subcommand (initialize the project only, useful for the preliminary tweaking)
Expand All @@ -125,3 +125,21 @@ stm32pio changelog:
- Changed: set-up and tear-down stages are now done using 'unittest' API
- Changed: actualized .ioc file for the latest STM32CubeMX version (5.4.0 at the moment)
- Changed: improved help, docs, comments

ver. 0.95 (12.19):
- New: re-made patch() method: it can intelligently parses platformio.ini and substitute necessary options. Patch can now be a general .INI-format config
- New: test_get_state()
- New: upload to PyPI
- New: use regular expressions to test logging output format for both verbose and normal modes
- Fix: return -d as an optional argument to be able to execute a short form of the app
- Changed: subclass ConfigParser to add save() method (remove Stm32pio.save_config())
- Changed: resolve more TO-DOs (some cannot be achieved actually)
- Changed: improve setup.py
- Changed: replace traceback.print to 'logging' functionality
- Changed: no more mutable default arguments
- Changed: use inspect.cleandoc to place long multi-line strings in code
- Changed: rename _load_config_file(), ProjectState.PATCHED
- Changed: use interpolation=None for ConfigParser
- Changed: check whether there is already a platformio.ini file and warn in this case on PlatformIO init stage
- Changed: sort imports in the alphabetic order
- Changed: use configparser to test project patching
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 Andrey Chufyrev aka ussserrr
Copyright (c) 2020 Andrey Chufyrev aka ussserrr

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
13 changes: 7 additions & 6 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# TODOs

- [ ] Middleware support (FreeRTOS, etc.)
- [ ] Arduino framework support
- [ ] Arduino framework support (needs research to check if it is possible)
- [ ] Add more checks, for example when updating the project (`generate` command), check for boards matching and so on...
- [x] Function annotations
- [ ] GUI. For example, drop the folder into small window (with checkboxes corresponding with CLI options) and get the output. At left is a list of recent projects
Expand All @@ -25,10 +25,11 @@
- [x] `str(path)` -> `path` were possible
- [x] Check `start_editor()` for different input
- [x] Test on Python 3.6 (pyenv)
- [ ] Test for `get_state()` (as sequence of states (see scratch.py))
- [x] Test for `get_state()` (as sequence of states (see scratch.py))
- [x] Remake `get_state()` as property value (read-only getter with decorator)
- [ ] If the project path is a unique identifier of the project in our code maybe we can remake `Stm32pio` class as a subclass of `pathlib.Path` and then reference it like `self` and not `self.project_path`. It would be more consistent also, as now `project_path` is perceived like any other config parameter that somehow is appeared to exist outside of a config instance but then it will be a core identifier, a truly `self` value.
- [x] Try to invoke stm32pio as module (-m), from different paths...
- [ ] Logs format test (see prepared regular expressions)
- [ ] Some non-intrusive installation test (may be some sort of temp virtualenv...)
- [ ] We look for some snippets of strings in logs and output for the testing code but we hard-code them and this is not good
- [x] Logs format test (see prepared regular expressions)
- [ ] We look for some snippets of strings in logs and output for the testing code but we hard-code them and this is not good, probably
- [x] Do we really need *sys.exc_info() ?
- [x] See logging.exception and sys_exc argument for logging.debug
- [x] Make `save_config()` a part of the `config` i.e. `project.config.save()` (subclass `ConfigParser`)
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
author='ussserrr',
author_email='[email protected]',
description="Small cross-platform Python app that can create and update PlatformIO projects from STM32CubeMX .ioc "
"files.",
"files. It uses STM32CubeMX to generate a HAL-framework based code and alongside creates PlatformIO "
"project with the compatible framework specified",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/ussserrr/stm32pio",
Expand All @@ -24,6 +25,7 @@
"Environment :: Console",
"Topic :: Software Development :: Embedded Systems"
],
python_requires='>=3.6',
include_package_data=True,
entry_points={
'console_scripts': [
Expand Down
20 changes: 10 additions & 10 deletions stm32pio/app.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__version__ = '0.9'
__version__ = '0.95'

import argparse
import logging
import sys
import pathlib
import traceback
import sys
from typing import Optional


Expand Down Expand Up @@ -42,7 +41,7 @@ def parse_args(args: list) -> Optional[argparse.Namespace]:

# Common subparsers options
for p in [parser_init, parser_new, parser_generate, parser_clean]:
p.add_argument('-d', '--directory', dest='project_path', default=pathlib.Path.cwd(), required=True,
p.add_argument('-d', '--directory', dest='project_path', default=pathlib.Path.cwd(), required=False,
help="path to the project (current directory, if not given)")
for p in [parser_init, parser_new]:
p.add_argument('-b', '--board', dest='board', required=False, help="PlatformIO name of the board")
Expand All @@ -59,7 +58,7 @@ def parse_args(args: list) -> Optional[argparse.Namespace]:
return parser.parse_args(args)


def main(sys_argv: list = sys.argv[1:]) -> int:
def main(sys_argv=None) -> int:
"""
Can be used as high-level wrapper to do complete tasks
Expand All @@ -70,18 +69,21 @@ def main(sys_argv: list = sys.argv[1:]) -> int:
sys_argv: list of strings
"""

if sys_argv is None:
sys_argv = sys.argv[1:]

args = parse_args(sys_argv)

# Logger instance goes through the whole program.
# Currently only 2 levels of verbosity through the '-v' option are counted (INFO (default) and DEBUG (-v))
logger = logging.getLogger('stm32pio')
handler = logging.StreamHandler()
logger.addHandler(handler)
if args is not None and args.verbose:
if args is not None and args.subcommand is not None and args.verbose:
logger.setLevel(logging.DEBUG)
handler.setFormatter(logging.Formatter("%(levelname)-8s %(funcName)-26s %(message)s"))
logger.debug("debug logging enabled")
elif args is not None:
elif args is not None and args.subcommand is not None:
logger.setLevel(logging.INFO)
handler.setFormatter(logging.Formatter("%(levelname)-8s %(message)s"))
else:
Expand Down Expand Up @@ -129,9 +131,7 @@ def main(sys_argv: list = sys.argv[1:]) -> int:

# library is designed to throw the exception in bad cases so we catch here globally
except Exception as e:
logger.error(e)
if logger.getEffectiveLevel() <= logging.DEBUG: # verbose
traceback.print_exception(*sys.exc_info())
logger.exception(e, exc_info=logger.getEffectiveLevel() <= logging.DEBUG)
return -1

logger.info("exiting...")
Expand Down
Loading

0 comments on commit ea51af3

Please sign in to comment.