Skip to content

Conversation

@makubacki
Copy link
Member

Improvements for script maintainability and user experience. Also adds code documentation, type hints, and runs the code through flake8.


ComToTcpServer.py: Print errors when connecting to pipes or com ports

Makes it easier to understand why the script failed.


ComToTcpServer: Non-functional cleanup

  • Use f-strings consistently
  • Remove unused module imports
  • Make a print statement more concise/readable

ComToTcpServer: Prevent ascii decode errors writing to the log files

Currently a character that fails to decode as ascii will result
in an exception and stop logging. This change ignores the failure
and allows logging to continue.


ComToTcpServer: Fix all flake8 issues, add type hints, and doc comments

Non-functional change to pass flake8 checks and improve code
readability with type hints and doc comments.


ComToTcpServer: Refactor logging

Replace custom log file handling with Python loggers for improved
control, cleaner output, and cleaner code.

  • Replace --logfile with --log-path supporting both files
    and directories
    • Giving a directory generates new timestamped log files on
      each run
    • Add separate --script-log-file for operational logging
  • Separate loggers for script operations and serial data
  • Add a --show-direction flag for optional IN/OUT directional
    indicators in log output
    • More clearly indicates data flow direction than the previous
      prefixing method separators (<<< and >>>)
  • Implement line buffering to prevent newlines in chunked data
  • Strip carriage returns to eliminate blank lines in logs

@makubacki makubacki self-assigned this Dec 15, 2025
vineelko
vineelko approved these changes Dec 15, 2025
Copy link
Collaborator

@cfernald cfernald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a known issue with the build only running on extension changes that prevents merges. Let me open a PR to fix that so your pipelines will run, at least until more build pipeline operations are added.

@cfernald
Copy link
Collaborator

There is a known issue with the build only running on extension changes that prevents merges. Let me open a PR to fix that so your pipelines will run, at least until more build pipeline operations are added.

This should be resolved after updating the branch.

Makes it easier to understand why the script failed.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
- Use f-strings consistently
- Remove unused module imports
- Make a print statement more concise/readable

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Currently a character that fails to decode as ascii will result
in an exception and stop logging. This change ignores the failure
and allows logging to continue.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Non-functional change to pass flake8 checks and improve code
readability with type hints and doc comments.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Replace custom log file handling with Python loggers for improved
control, cleaner output, and cleaner code.

- Replace `--logfile` with `--log-path` supporting both files
  and directories
  - Giving a directory generates new timestamped log files on
    each run
  - Add separate `--script-log-file` for operational logging
- Separate loggers for script operations and serial data
- Add a `--show-direction` flag for optional IN/OUT directional
  indicators in log output
  - More clearly indicates data flow direction than the previous
    prefixing method separators (`<<<` and `>>>`)
- Implement line buffering to prevent newlines in chunked data
- Strip carriage returns to eliminate blank lines in logs

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
@makubacki makubacki force-pushed the comtotcp_script_updates branch from eb322d9 to feb68a3 Compare December 15, 2025 22:39
@makubacki makubacki merged commit a026e55 into microsoft:main Dec 15, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants