Browse Source

download: Run pre-commit hook, update app names

Andreas Berthoud 4 years ago
parent
commit
031b6b5839
  1. 29
      download.py

29
download.py

@ -1,18 +1,26 @@
import logging import logging
import subprocess import subprocess
from pathlib import Path from pathlib import Path
from typing import Sequence, Union from typing import Sequence
from typing import Union
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger("Download") logger = logging.getLogger("Download")
# APPLICATION_NAME = "nucleo-wb55-ble"
APPLICATION_NAME = "nucleo-wb55-dongle-ble" APPLICATION_NAME = "nucleo-wb55-dongle-ble"
#APPLICATION_NAME = "nucleo-wb55-dongle-usb" # APPLICATION_NAME = "nucleo-wb55-dongle-usb"
#APPLICATION_NAME = "nucleo-wb55-dongle-blinky" # APPLICATION_NAME = "nucleo-wb55-dongle-blinky"
PORT="USB1" PORT = "USB1"
CLI_PATH = Path("/Applications/STMicroelectronics/STM32Cube/STM32CubeProgrammer/STM32CubeProgrammer.app/Contents/MacOs/bin/STM32_Programmer_CLI") CLI_PATH = Path(
ELF_FILE = Path.home() / Path(f"Documents/git/nucleo-playground-workspace/{APPLICATION_NAME}/Debug/{APPLICATION_NAME}.elf") "/Applications/STMicroelectronics/STM32Cube/STM32CubeProgrammer/"
"STM32CubeProgrammer.app/Contents/MacOs/bin/STM32_Programmer_CLI",
)
ELF_FILE = Path.home() / Path(
f"Documents/git/nucleo-playground-workspace/{APPLICATION_NAME}/"
"Debug/{APPLICATION_NAME}.elf",
)
def execute_command( def execute_command(
@ -26,17 +34,17 @@ def execute_command(
) )
def _poll_stdout() -> str: def _poll_stdout() -> str:
return process.stdout.readline().decode() return process.stdout.readline().decode() # type: ignore
exit_code = None exit_code = None
command_logger = logger.getChild("Programmer") command_logger = logger.getChild("Programmer")
while exit_code is None: while exit_code is None:
for line in iter(_poll_stdout, ''): for line in iter(_poll_stdout, ""):
command_logger.info(line.rstrip()) command_logger.info(line.rstrip())
exit_code = process.poll() exit_code = process.poll()
for line in iter(_poll_stdout, ''): for line in iter(_poll_stdout, ""):
command_logger.info(line.rstrip()) # flush pipe command_logger.info(line.rstrip()) # flush pipe
logger.debug(f"Coomand finished with exit code {exit_code}") logger.debug(f"Coomand finished with exit code {exit_code}")
@ -48,7 +56,8 @@ def download():
str(CLI_PATH), str(CLI_PATH),
"-c", "-c",
f"port={PORT}", f"port={PORT}",
"-w", str(ELF_FILE), "-w",
str(ELF_FILE),
] ]
execute_command(command) execute_command(command)

Loading…
Cancel
Save