Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webrepl_cli.py: Add support for uploading directory. #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mo-vic
Copy link

@mo-vic mo-vic commented Aug 16, 2024

Allow user to upload directory recursively

for example:

$ ./webrepl_cli.py -p x ./package 192.168.4.1:/

Description:

This patch introduces the ability to upload entire directories to a MicroPython device via WebREPL. This enhancement is particularly useful when working with Python packages or other resources that consist of multiple files and subdirectories. Previously, users had to upload files one by one, which was tedious and time-consuming, especially for larger projects.

Key Features:

Directory Upload: Added the put_dir function to recursively upload a local directory and its contents to the remote device.
Directory Creation: Added a helper function create_directory to remotely create directories on the MicroPython device.
Command Execution: Implemented the run_command function to facilitate the execution of arbitrary commands on the device via WebREPL.
Main Function Enhancement: Updated the main function to automatically detect whether the user intends to upload a file or a directory and handle the operation accordingly.
Improved Help Information: Updated the help message to reflect the new functionality.

Use Case:

This feature is essential for scenarios where developers need to upload Python packages, resources, or any structured data to a device running MicroPython. By supporting directory uploads, this patch streamlines the development and deployment process, making it more efficient and less error-prone.

Testing:

This patch has been tested in various scenarios, including:

  1. Uploading single files
  2. Uploading flat directories (only files, no subdirectories)
  3. Uploading nested directories
  4. Handling invalid paths
    These tests confirm that the new functionality works as intended without introducing regressions or performance issues.

Backward Compatibility:

The changes are fully backward compatible. Existing workflows that involve uploading individual files remain unaffected.

Allow user to upload directory recursively,
for example:

    $ ./webrepl_cli.py -p x ./package 192.168.4.1:/

Signed-off-by: movic <movic.chen@gmail.com>
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.

1 participant