Skip to content

Commit fd1ffad

Browse files
committed
--fs-upload
1 parent fac3406 commit fd1ffad

2 files changed

Lines changed: 365 additions & 76 deletions

File tree

meshtastic/__main__.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,24 @@ def setSimpleConfig(modem_preset):
10441044
closeNow = True
10451045
print(f"Downloaded '{node_src}' to '{destination_path}'.")
10461046

1047+
if args.fs_upload:
1048+
if len(args.fs_upload) > 2:
1049+
print("--fs-upload expects at most two arguments: <host_src> [device_dst]")
1050+
return
1051+
if args.dest != BROADCAST_ADDR:
1052+
print("Uploading to a remote node is not supported.")
1053+
return
1054+
host_src = args.fs_upload[0]
1055+
device_dst = args.fs_upload[1] if len(args.fs_upload) == 2 else "/"
1056+
try:
1057+
remote_path = interface.upload_file(host_src, device_dst)
1058+
except MeshInterface.MeshInterfaceError as ex:
1059+
closeNow = True
1060+
print(f"ERROR: {ex}")
1061+
return
1062+
closeNow = True
1063+
print(f"Uploaded '{host_src}' to '{remote_path}'.")
1064+
10471065
if args.qr or args.qr_all:
10481066
closeNow = True
10491067
url = interface.getNode(args.dest, True, **getNode_kwargs).getURL(includeAll=args.qr_all)
@@ -1865,6 +1883,13 @@ def addLocalActionArgs(parser: argparse.ArgumentParser) -> argparse.ArgumentPars
18651883
help="Download a file from the node filesystem. Provide NODE_SRC and optionally a HOST_DST path.",
18661884
)
18671885

1886+
group.add_argument(
1887+
"--fs-upload",
1888+
nargs="+",
1889+
metavar=("HOST_SRC", "DEVICE_DST"),
1890+
help="Upload a file to the node filesystem. Provide HOST_SRC and optionally a DEVICE_DST path (defaults to '/').",
1891+
)
1892+
18681893
return parser
18691894

18701895
def addRemoteActionArgs(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:

0 commit comments

Comments
 (0)