Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.14.0
63 changes: 63 additions & 0 deletions meshtastic/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,49 @@ def setSimpleConfig(modem_preset):
print("--show-fields can only be used with --nodes")
return

if args.fs_ls:
if args.dest != BROADCAST_ADDR:
print("Listing filesystem of a remote node is not supported.")
return
closeNow = True
interface.showFileSystem()

if args.fs_download:
if len(args.fs_download) > 2:
print("--fs-download expects at most two arguments: <node_src> [host_dst]")
return
if args.dest != BROADCAST_ADDR:
print("Downloading from a remote node is not supported.")
return
node_src = args.fs_download[0]
host_dst = args.fs_download[1] if len(args.fs_download) == 2 else "."
try:
destination_path = interface.download_file(node_src, host_dst)
except MeshInterface.MeshInterfaceError as ex:
closeNow = True
print(f"ERROR: {ex}")
return
closeNow = True
print(f"Downloaded '{node_src}' to '{destination_path}'.")

if args.fs_upload:
if len(args.fs_upload) > 2:
print("--fs-upload expects at most two arguments: <host_src> [device_dst]")
return
if args.dest != BROADCAST_ADDR:
print("Uploading to a remote node is not supported.")
return
host_src = args.fs_upload[0]
device_dst = args.fs_upload[1] if len(args.fs_upload) == 2 else "/"
try:
remote_path = interface.upload_file(host_src, device_dst)
except MeshInterface.MeshInterfaceError as ex:
closeNow = True
print(f"ERROR: {ex}")
return
closeNow = True
print(f"Uploaded '{host_src}' to '{remote_path}'.")

if args.qr or args.qr_all:
closeNow = True
url = interface.getNode(args.dest, True, **getNode_kwargs).getURL(includeAll=args.qr_all)
Expand Down Expand Up @@ -1827,6 +1870,26 @@ def addLocalActionArgs(parser: argparse.ArgumentParser) -> argparse.ArgumentPars
default=None
)

group.add_argument(
"--fs-ls",
help="List filesystem entries reported by the local node",
action="store_true",
)

group.add_argument(
"--fs-download",
nargs="+",
metavar=("NODE_SRC", "HOST_DST"),
help="Download a file from the node filesystem. Provide NODE_SRC and optionally a HOST_DST path.",
)

group.add_argument(
"--fs-upload",
nargs="+",
metavar=("HOST_SRC", "DEVICE_DST"),
help="Upload a file to the node filesystem. Provide HOST_SRC and optionally a DEVICE_DST path (defaults to '/').",
)

return parser

def addRemoteActionArgs(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
Expand Down
Loading