diff --git a/CHANGELOG b/CHANGELOG index 69c1a3f..8b08d6d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -126,7 +126,7 @@ stm32pio changelog: - 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): + ver. 0.95 (15.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 @@ -143,3 +143,14 @@ stm32pio changelog: - 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 + + ver. 0.96 (17.12.19): + - Fix: generate_code() doesn't destroy the temp folder after execution + - Fix: improved and actualized docs, comments, annotations + - Changed: print Python interpreter information on testing + - Changed: move some asserts inside subTest context managers + - Changed: rename pio_build() => build() + - Changed: take out to the settings.py the width of field in a log format string + - Changed: use file statistic to check its size instead of reading the whole content + - Changed: more logging output + - Changed: change some methods signatures to return result value diff --git a/stm32pio/app.py b/stm32pio/app.py index 10f5310..bff187f 100755 --- a/stm32pio/app.py +++ b/stm32pio/app.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -__version__ = '0.95' +__version__ = '0.96' import argparse import logging diff --git a/stm32pio/lib.py b/stm32pio/lib.py index 222b663..35c81a5 100644 --- a/stm32pio/lib.py +++ b/stm32pio/lib.py @@ -313,8 +313,9 @@ def generate_code(self) -> int: # Use mkstemp() instead of higher-level API for compatibility with Windows (see tempfile docs for more details) cubemx_script_file, cubemx_script_name = tempfile.mkstemp() - # buffering=0 leads to the immediate flushing on writing + # We should necessarily remove the temp directory, so do not let any exception break our plans try: + # buffering=0 leads to the immediate flushing on writing with open(cubemx_script_file, mode='w+b', buffering=0) as cubemx_script: # encode since mode='w+b' cubemx_script.write(self.config.get('project', 'cubemx_script_content').encode()) @@ -328,6 +329,8 @@ def generate_code(self) -> int: result = subprocess.run(command_arr, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # Or, for Python 3.7 and above: # result = subprocess.run(command_arr, capture_output=True) + except Exception as e: + raise e # re-raise an exception after the final block finally: pathlib.Path(cubemx_script_name).unlink()