Skip to content

Commit 8ed7097

Browse files
authored
Merge pull request #17 from ussserrr/dev
v1.30
2 parents df14cef + 79924f1 commit 8ed7097

File tree

23 files changed

+1628
-1126
lines changed

23 files changed

+1628
-1126
lines changed

CHANGELOG.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,5 +230,45 @@
230230
- Changed: remove `from __future__ import annotations` statements
231231

232232
## ver. 1.21 (19.04.20)
233-
- Fixed: GUI. All paths are now reliably treated both for QML and Python
234-
- Changed: README installation process actualized
233+
- Fixed: GUI. All resorce paths are now reliably treated both for QML and Python
234+
- Changed: README installation process actualized
235+
236+
## ver. 1.30 (05.05.20)
237+
- New: `examples` folder (currently, only an embedding one (updated and moved from the wiki page))
238+
- New: `docs` folder with some useful internal descriptions (currently, only a logging schematic (with sources))
239+
- New: issues guide for GitHub (OS, content of the config, project tree, enable verbose, etc.)
240+
- New: GUI. Show the app version in "About" dialog
241+
- New: GUI. Handle a theoretical app loading error
242+
- New: GUI. Notify a user that the "board" parameter is empty
243+
- New: GUI. The app can be started from CLI
244+
- New: GUI. `ProjectListItem.fromStartup` property
245+
- New: GUI. Expose projects' `config` to QML
246+
- New: Tests. Preserving user files and folders on regeneration
247+
- New: Tests. 'verbose' and 'non-verbose' tests as `subTest` (also `should_log_error_...`)
248+
- New: Inform a user that given parameters have overridden the config ones
249+
- Fixed: GUI. `TypeError: Cannot read property 'actionRunning' of null` (deconstruction order) (on project deletion only)
250+
- Fixed: GUI. The app now can handle as many projects as needed (use QML `DelegateModel` to store state in the `ListView` delegate)
251+
- Fixed: #13 (new parsing algo to analyze the CubeMX output)
252+
- Changed: improved `typing` annotations
253+
- Changed: wrap imports into `try...except`
254+
- Changed: new README logo, add sources (draw.io)
255+
- Changed: GUI. Icons instead of a text for "Clean", "Open editor"
256+
- Changed: GUI. Gray out "stage" line in all projects except current
257+
- Changed: GUI. 2 types of logging formatters for 2 verbosity levels
258+
- Changed: GUI. More general `goToProject` signal instead of `duplicateFound`
259+
- Changed: GUI. Projects list is now saves to `Settings` in a separate thread using `QThreadPool` and `saveInSettings()` method
260+
- Changed: GUI. `ProjectsList.each_project_is_duplicate_of` generator
261+
- Changed: GUI. Optimized project' `state` handling
262+
- Changed: GUI. Insert board ID from config, if there is one, focus on that input field by default
263+
- Changed: logging mechanics is remade from scratch:
264+
- add `stm32pio.app.setup_logging()`, `should_setup_logging` argument fo `stm32pio.app.setup_main()`. This also fixes annoying logging errors on testing because the loggers interfere with each other
265+
- `stm32pio.util.ProjectLoggerAdapter()` subclass as an individual logger for every project
266+
- add `stm32pio.util.log_current_exception()`
267+
- get rid of `log_record_factory` substitution
268+
- add `stm32pio.util.Verbosity` entity (enum). Acts like an additional degree of freedom for the logging setup
269+
- rewritten `stm32pio.util.DispatchingFormatter`
270+
- GUI. New `BuffersDispatchingHandler()` class
271+
- and some others (see block schema)
272+
- Changed: better parameters and configs merging
273+
- Changed: make `platformio_ini_is_patched` a property instead of function
274+
- Changed: improved in-code docs

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The [GUI version](/stm32pio_gui) is available, too.
1313
> - [Requirements](#requirements)
1414
> - [Installation](#installation)
1515
> - [Usage](#usage)
16+
> - [GUI from CLI](#gui-from-cli)
1617
> - [Project patching](#project-patching)
1718
> - [Embedding](#embedding)
1819
> - [Example](#example)
@@ -49,7 +50,7 @@ stm32pio-repo/ $ python3 stm32pio/app.py # or
4950
stm32pio-repo/ $ python3 -m stm32pio # or
5051
any-path/ $ python3 path/to/stm32pio-repo/stm32pio/app.py
5152
```
52-
(we assume python3 and pip3 hereinafter). It is possible to run the app like this from anywhere.
53+
(we assume `python3` and `pip3` hereinafter). It is possible to run the app like this from anywhere.
5354

5455
However, it's handier to install the utility to be able to run stm32pio from anywhere. Use
5556
```shell script
@@ -94,6 +95,12 @@ $ python app.py --help
9495
```
9596
to see help on available commands. Find the copy of its output on the [project wiki](https://github.com/ussserrr/stm32pio/wiki/stm32pio-help) page, also.
9697

98+
### GUI from CLI
99+
You can start the [GUI version](/stm32pio_gui) using `gui` subcommand and pass some of the arguments to it:
100+
```shell script
101+
$ stm32pio gui -d ./sample-project -b discovery_f4
102+
```
103+
97104
### Project patching
98105

99106
Note, that the patch operation (which takes the CubeMX code and PlatformIO project to the compliance) erases all the comments (lines starting with `;`) inside the `platformio.ini` file. They are not required anyway, in general, but if you need them for some reason please consider to save the information somewhere else.
@@ -102,7 +109,7 @@ For those who want to modify the patch (default one is at [`settings.py`](/stm32
102109

103110
### Embedding
104111

105-
You can also use stm32pio as an ordinary Python package and embed it in your own application. Find the minimal example at the [project wiki](https://github.com/ussserrr/stm32pio/wiki/Embedding-example) page to see some possible ways of implementing this. Basically, you need to import `stm32pio.lib` module (where the main `Stm32pio` class resides), (optionally) set up a logger and you are good to go. If you prefer higher-level API similar to the CLI version, use `main()` function in `app.py` passing the same CLI arguments to it (except the actual script name). Also, take a look at the CLI ([`app.py`](/stm32pio/app.py)) or GUI versions.
112+
You can also use stm32pio as an ordinary Python package and embed it in your own application. Find the minimal example at the [examples](/examples) to see some possible ways of implementing this. Basically, you need to import `stm32pio.lib` module (where the main `Stm32pio` class resides), (optionally) set up a logger and you are good to go. If you prefer higher-level API similar to the CLI version, use `main()` function in `app.py` passing the same CLI arguments to it (except the actual script name). Also, take a look at the CLI ([`app.py`](/stm32pio/app.py)) or GUI versions.
106113

107114

108115
## Example
@@ -138,16 +145,12 @@ There are some tests in file [`test.py`](/stm32pio/tests/test.py) (based on the
138145
```shell script
139146
stm32pio-repo/ $ python -m unittest -b -v
140147
```
141-
or
142-
```shell script
143-
stm32pio-repo/ $ python -m stm32pio.tests.test -b -v
144-
```
145148
to test the app. It uses STM32F0 framework to generate and build a code from the test [`stm32pio-test-project.ioc`](/stm32pio-test-project/stm32pio-test-project.ioc) project file. Please make sure that the test project folder is clean (i.e. contains only an .ioc file) before running the test otherwise it can lead to some cases failing. Tests automatically create temporary directory (using `tempfile` Python standard module) where all actions are performed.
146149

147150
For the specific test suite or case you can use
148151
```shell script
149-
stm32pio-repo/ $ python -m unittest stm32pio.tests.test.TestIntegration -b -v
150-
stm32pio-repo/ $ python -m unittest stm32pio.tests.test.TestCLI.test_verbose -b -v
152+
stm32pio-repo/ $ python -m unittest tests.test_integration.TestIntegration -b -v
153+
stm32pio-repo/ $ python -m unittest tests.test_cli.TestCLI.test_verbosity -b -v
151154
```
152155

153156

TODO.md

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,59 @@
11
# TODOs
22

3-
## Business logic, business features
4-
- [ ] Issues guide for the GitHub (OS, content of the config, project tree, enable verbose)
3+
## Business logic, general features
54
- [ ] GitHub CHANGELOG - separate New, Fixed, Changed into paragraphs
65
- [ ] Middleware support (FreeRTOS, etc.)
76
- [ ] Arduino framework support (needs research to check if it is possible)
87
- [ ] Create VSCode plugin
8+
- [ ] UML diagrams (core, GUI back- and front-ends, thread flows, events, etc.)
9+
- [ ] CI is possible (Arch's AUR has the STM32CubeMX package, also there is a direct link). Deploy Docker one in Azure Pipelines, basic at Travis CI
910

1011
## GUI version
11-
- [ ] Handle the initialization error (when boards are receiving)
12-
- [ ] Maybe `data()` `QAbstractListModel` method can be used instead of custom `get()`
12+
- [ ] Obtain boards on demand (not at the startup)
1313
- [ ] Can probably detect Ctrl and Shift clicks without moving the mouse first
14-
- [ ] Notify the user that the 'board' parameter is empty
1514
- [ ] Mac: sometimes auto turned off shift highlighting after action (hide-restore helps)
1615
- [ ] Some visual flaws when the window have got resized (e.g. 'Add' button position doesn't change until the list gets focus, 'Log' area crawls onto the status bar)
17-
- [ ] Gray out "stage" line in all projects except current
1816
- [ ] Tests (research approaches and patterns)
19-
- [ ] Test performance with a large number of projects in the model. First test was made:
20-
1. Some projects occasionally change `initLoading` by itself (probably Loader unloads the content) (hence cannot click on them, busy indicator appearing)
17+
- [ ] Remade the list item to use States, too. Probably, such properties need to be implemented:
18+
```
19+
state: {
20+
loaded,
2121

22-
Note: Delegates are instantiated as needed and may be destroyed at any time. They are parented to ListView's contentItem, not to the view itself. State should never be stored in a delegate.
22+
visitedAfterInstantiating,
2323

24-
Use `id()` in `setInitInfo()`. Or do not use ListView at all (replace by Repeater, for example) as it can reset our "notifications"
25-
2. Some projects show OK even after its deletion (only the app restart helps)
24+
actionRunning,
25+
lastActionStatus,
26+
visitedAfterAction,
27+
...
28+
}
29+
```
2630
- [ ] Test with different timings
2731
- [ ] Divide on multiple modules (both Python and QML)
2832
- [ ] Implement other methods for Qt abstract models
2933
- [ ] Warning on 'Clean' action (maybe the window with a checkbox "Do not ask in the future" (QSettings parameter))
30-
- [ ] 2 types of logging formatters for 2 verbosity levels
31-
- [ ] `TypeError: Cannot read property 'actionRunning' of null` (deconstruction order) (on project deletion only)
3234
- [ ] QML logging - pass to Python' `logging` and establish a similar format. Distinguish between `console.log()`, `console.error()` and so on
3335
- [ ] Lost log box autoscroll when manually scrolling between the actions
3436
- [ ] Crash on shutdown in Win and Linux (errors such as `[QML] CRITICAL QThread: Destroyed while thread is still running Process finished with exit code 1073741845`)
35-
- [ ] Start with a folder opened if it was provided on CLI (for example, `stm32pio_gui .`)
36-
- [ ] Linux:
37-
- Not a monospace font in the log area
37+
- [ ] Linux: Not a monospaced font in the log area
38+
- [ ] Temporarily pin projects with currently running actions to the top (and stay there on scrolling). See QML Package type
3839

3940
## Core library
40-
- [ ] Add more checks, for example when updating the project (`generate` command), check for boards matching and so on...
41-
- [x] Remove casts to string where we can use path-like objects (related to Python version as new ones receive path-like objects arguments while old ones aren't)
41+
- [ ] when updating the project (`generate` command), check for boards match
42+
- [ ] Remove casts to string where we can use path-like objects (related to a Python version as new ones receives path-like objects arguments while old ones aren't)
4243
- [ ] 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 (e.g. 'DEBUG')
43-
- [ ] Store a folder initial content in .ini config and ignore it on clean-up process. Allow the user to modify such list (i.e. list of exclusion) in the config file. Mb some integration with `.gitignore`
44+
- [ ] Store an initial content of the folder in .ini config and ignore it on clean-up process. Allow the user to modify such list (i.e. list of exclusion) in the config file. Mb some integration with `.gitignore`
4445
- [ ] at some point check for all tools (CubeMX, ...) to be present in the system (both CLI and GUI) (global `--check` command (as `--version`), also before execution of the full cycle (no sense to start if some tool doesn't exist))
4546
- [ ] generate code docs (help user to understand an internal mechanics, e.g. for embedding). Can be uploaded to the GitHub Wiki
46-
- [ ] colored logs, maybe (brakes zero-dependency principle)
47-
- [ ] check logging work when embed stm32pio lib in a third-party stuff (no logging setup at all)
48-
- [ ] merge subprocess pipes to one where suitable (i.e. `stdout` and `stderr`)
49-
- [ ] redirect subprocess pipes to `DEVNULL` where suitable to suppress output (tests)
50-
- [ ] Two words about a synchronous nature of the lib and user's responsibility of async wrapping (if needed). Also, maybe migrate to async/await approach in the future
47+
- [ ] colored logs, maybe (breaks zero-dependency principle)
48+
- [ ] maybe migrate to async/await approach in the future (return some kind of a "remote controller" to control the running action)
5149
- [ ] `__init__`' `parameters` dict argument schema (Python 3.8 feature).
52-
- [ ] See https://docs.python.org/3/howto/logging-cookbook.html#context-info to maybe remade current logging schema (current is, perhaps, a cause of the strange error while testing (in the logging thread), also modifies global settings (log message factory))
53-
- [ ] UML diagrams (core, GUI back- and front-ends, thread flows, events, etc.)
54-
- [ ] CI is possible (Arch's AUR has the STM32CubeMX package, also there is a direct link). Deploy Docker one in Azure Pipelines, basic at Travis CI
55-
- [ ] Test preserving user files and folders on regeneration and mb other operations
56-
- [ ] Move special formatters inside the library. It is an implementation detail actually that we use subprocesses and so on
57-
- [ ] Mb store the last occurred exception traceback in .ini file and show on some CLI command (so we don't necessarily need to turn on the verbose mode). And, in general, we should show the error reason right off
58-
- [ ] 'verbose' and 'non-verbose' tests as `subTest` (also `should_log_error_...`)
50+
- [ ] Mb store the last occurred exception traceback in .ini file and show on some CLI command (so we don't necessarily need to turn on the verbose mode and repeat this action). And, in general, we should show the error reason right off
5951
- [ ] the lib sometimes raising, sometimes returning the code and it is not consistent. While the reasons behind such behavior are clear, would be great to always return a result code and raise the exceptions in the outer scope, if there is need to
6052
- [ ] check board (no sense to go further on 'new' if the board in config.ini is not correct)
61-
- [ ] check if `platformio.ini` config will be successfully parsed when there are interpolation and/or empty parameters
62-
- [x] check if `.ioc` file is a text file on project initialization. Let `_find_ioc_file()` method to use explicitly provided file (useful for GUI). Maybe let user specify it via CLI
63-
- [ ] mb add CLI command for starting the GUI version (for example, `stm32pio --gui`)
6453
- [ ] test using virtualenv
54+
- [ ] test for different `.ioc` files (i.e. F0, F1, F4 and so on) as it is not the same actually
55+
- [ ] mb allow to use an arbitrary strings (arrays of str) to specify tools commands in stm32pio.ini (shell=True or a list of args (split a string))
56+
- [ ] cache boards for a small interval of time
57+
- [ ] count another '-v' as '-v' for PlatformIO calls (slider in GUI settings window)
58+
- [ ] Project' name (path) can be reused so cannot be used as a unique identifier but so is id(self)? Probably it is better to use a path (human-readable)
59+
- [ ] Analyze `.ioc` file for the wrong framework/parameters

docs/logging/logging.drawio

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<mxfile host="app.diagrams.net" modified="2020-05-04T16:20:00.248Z" agent="5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Safari/605.1.15" etag="wxT5b3SQhpxaQQsfQtWn" version="13.0.1" type="device"><diagram id="lKRTrCdrkXKAPuY9JuVQ" name="Page-1">7V1bl9o2EP41nLYPcGzLNx4XNiQ5Jc02254kTxwBwrhrW44sskt/fSVfwLYEOAVf2JA8rDWWbFkz82k0MxI9MPZf3hIYrj/gJfJ6mrJ86YH7nqYBdaixP5yyTSiaZVoJxSHuMqGpe8Kj+y9KiUpK3bhLFBUqUow96oZF4gIHAVrQAg0Sgp+L1VbYK741hA4SCI8L6InUz+6SrhOqrVl7+jvkOuvszao5TO74MKucfkm0hkv8nCOBNz0wJhjT5Mp/GSOPj142Lkm7yYG7u44RFNAqDTbr6fDTw8PceT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V6rbcavdbF6PU0WeR8xuTpClVI5igAsk2B9fmlxNj1nx+mjPD27/fCYGbeF9ePD2LND13ZH0S5Nh10I+28RfFGzhFcPDkxo2T+qvhld1G4d4XBrLByXzhrR2l/7teU8pNm7/iQaJPFMlAG7gIHK5eJAOEuIEZdQgrZH05n08Yk8qHn9YP+iskvK2rMMJiYlq0qZv+ZNcPPfQ9u8Yb2Vc0ehNwPVZSSd8j7jvg3SlxXJZedoqhDAC4kSWbpMC9VsiaWuZzsugTJusaodDePkdOrhqX1ls6RKx8HNTQasKnEIPhVnCJ56ZV5ltTY2oxhdcjqep3HSOqVg+fn7i37n/ov7L4yGzgOLhuVn/NgSBEIhiIQNHoypHWNe1a6ueHN0JpS+PPSozRBA69k3SVYLPLDWIwGp1Gz3RT6/CSaVx61cPKhWWEO7aZGVY3aJjLdvNM720GxE0itAb+kcfpI1ds5hj8KLeXNvdLT1xo9yDD7VZsuzMxnWugFbMmZ623DS9WodUvwYoLyfKcXLPQKLdQmAiXG6YNVX7NNb5a5ZLVs05vaq0GObtolploROECr2WRZN39OvVSUMhZKTpdpVi9bzld4/XpZdb0AWl2Bm6cN+Fesl0CwUdrWS6tDlvaV+8Csyomg7QS9bLsc9GrAPrZE+/h2hlPCjvKh56om2s7NHuJki+B8Y5aUWaraOq/EtJfx9H3yoRHPUTnAqarsKTm3UyjX9J6YJXKQcQKLL8AKUPZW6ZIpVG304ERbDOzHuUevnRWq8GucdfKCFfe/Xp1MT/sfAQdv/gM=</diagram></mxfile>

docs/logging/logging.png

321 KB
Loading

examples/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Examples
2+
This directory contains some useful examples related to the project.
3+
4+
## Table of contents
5+
> - [embedding](#embedding)
6+
7+
## Embedding
8+
Refer to this script to see a minimal basic setup enough to perform the most of tasks with stm32pio projects in your code (i.e. how to establish a core library (`stm32pio` folder) in a 3rd party tools).

0 commit comments

Comments
 (0)