How to use the stm32pio.app function in stm32pio

To help you get started, we’ve selected a few stm32pio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ussserrr / stm32pio / tests / test_cli.py View on Github external
def test_clean(self):
        for case in ['--quiet', 'yes', 'no']:
            with self.subTest(case=case):
                # Create files and folders
                test_file = FIXTURE_PATH.joinpath('test.file')
                test_dir = FIXTURE_PATH.joinpath('test.dir')
                test_file.touch(exist_ok=False)
                test_dir.mkdir(exist_ok=False)

                # Clean ...
                if case == '--quiet':
                    return_code = stm32pio.app.main(sys_argv=['clean', case, '-d', str(FIXTURE_PATH)])
                else:
                    with unittest.mock.patch('builtins.input', return_value=case):
                        return_code = stm32pio.app.main(sys_argv=['clean', '-d', str(FIXTURE_PATH)])

                self.assertEqual(return_code, 0, msg="Non-zero return code")

                # ... look for remaining items ...
                if case == 'no':
                    with self.subTest():
                        self.assertTrue(test_file.is_file(), msg=f"{test_file} has been deleted")
                    with self.subTest():
                        self.assertTrue(test_dir.is_dir(), msg=f"{test_dir}/ has been deleted")
                else:
                    with self.subTest():
                        self.assertFalse(test_file.is_file(), msg=f"{test_file} is still there")
                    with self.subTest():
github ussserrr / stm32pio / tests / test_cli.py View on Github external
def test_non_verbose(self):
        """
        Capture the full output. We should not see any 'DEBUG' logging messages or STM32CubeMX CLI output. Logs format
        should match such a regex:

            ^(?=(INFO) {0,4})(?=.{8} ((?!( |build|pio_init|...))))
        """

        # inspect.getmembers is great but it triggers class properties leading to the unacceptable code execution
        methods = dir(stm32pio.lib.Stm32pio) + ['main']

        buffer_stdout, buffer_stderr = io.StringIO(), io.StringIO()
        with contextlib.redirect_stdout(buffer_stdout), contextlib.redirect_stderr(buffer_stderr):
            return_code = stm32pio.app.main(sys_argv=['generate', '-d', str(FIXTURE_PATH)])

        self.assertEqual(return_code, 0, msg="Non-zero return code")
        # stderr and not stdout contains the actual output (by default for the logging module)
        self.assertNotIn('DEBUG', buffer_stderr.getvalue(), msg="Verbose logging output has been enabled on stderr")
        self.assertEqual(len(buffer_stdout.getvalue()), 0, msg="All app output should flow through the logging module")

        regex = re.compile("^(?=(INFO) {0,4})(?=.{8} ((?!( |" + '|'.join(methods) + "))))", flags=re.MULTILINE)
        self.assertGreaterEqual(len(re.findall(regex, buffer_stderr.getvalue())), 1,
                                msg="Logs messages doesn't match the format")

        # The snippet of the actual STM32CubeMX output
        self.assertNotIn('Starting STM32CubeMX', buffer_stderr.getvalue(), msg="STM32CubeMX has printed its logs")
github ussserrr / stm32pio / stm32pio / __main__.py View on Github external
import sys

import stm32pio.app


if __name__ == '__main__':
    sys.exit(stm32pio.app.main())

stm32pio

Small cross-platform Python app that can create and update PlatformIO projects from STM32CubeMX .ioc files. It uses STM32CubeMX to generate a HAL-framework-based code and alongside creates PlatformIO project with compatible parameters to stick them both together. Both CLI and GUI editions are available

MIT
Latest version published 3 years ago

Package Health Score

48 / 100
Full package analysis

Similar packages