-
Notifications
You must be signed in to change notification settings - Fork 209
Add backup / restore admin commands #747
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
Draft
thebentern
wants to merge
8
commits into
master
Choose a base branch
from
backup-commands
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4bf61d4
Add backup / restore admin commands
thebentern 3008e03
Bump version
thebentern 336e515
Add args for cli
thebentern fb48fc2
Optionals
thebentern 2d88d8e
Good lawd I did that in a hurry
thebentern ec13bd3
Remove print
thebentern 5ee0264
Where's intellisense when you need it
thebentern 7422d9d
Update
thebentern File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,7 +59,7 @@ | |
have_powermon = False | ||
powermon_exception = e | ||
meter = None | ||
from meshtastic.protobuf import channel_pb2, config_pb2, portnums_pb2 | ||
from meshtastic.protobuf import admin_pb2, channel_pb2, config_pb2, portnums_pb2 | ||
from meshtastic.version import get_active_version | ||
|
||
def onReceive(packet, interface) -> None: | ||
|
@@ -462,6 +462,22 @@ def onConnected(interface): | |
waitForAckNak = True | ||
interface.getNode(args.dest, False, **getNode_kwargs).removeFavorite(args.remove_favorite_node) | ||
|
||
if args.backup_prefs: | ||
closeNow = True | ||
waitForAckNak = True | ||
print(f"Backing up preferences to {args.backup_prefs}") | ||
interface.getNode(args.dest, False, **getNode_kwargs).backupPreferences(args.backup_prefs) | ||
|
||
if args.restore_prefs: | ||
closeNow = True | ||
waitForAckNak = True | ||
interface.getNode(args.dest, False, **getNode_kwargs).restorePreferences(args.restore_prefs) | ||
|
||
if args.remove_backup_prefs: | ||
closeNow = True | ||
waitForAckNak = True | ||
interface.getNode(args.dest, False, **getNode_kwargs).removePreferencesBackups(args.remove_backup_prefs) | ||
|
||
if args.set_ignored_node: | ||
closeNow = True | ||
waitForAckNak = True | ||
|
@@ -1794,12 +1810,40 @@ def addRemoteAdminArgs(parser: argparse.ArgumentParser) -> argparse.ArgumentPars | |
action="store_true", | ||
) | ||
|
||
group.add_argument( | ||
"--backup-prefs", | ||
help="Tell the destination node to create a backup preferences file." | ||
"Location: 0 for local flash, 1 for SD card.", | ||
default=admin_pb2.AdminMessage.BackupLocation.FLASH, | ||
nargs="?", | ||
const=0, | ||
Comment on lines
+1817
to
+1819
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You probably want |
||
) | ||
|
||
group.add_argument( | ||
"--restore-prefs", | ||
help="Tell the destination node to remove backup preferences files." | ||
"Location: 0 for local flash, 1 for SD card.", | ||
default=admin_pb2.AdminMessage.BackupLocation.FLASH, | ||
nargs="?", | ||
const=0, | ||
) | ||
|
||
group.add_argument( | ||
"--remove-backup-prefs", | ||
help="Tell the destination node to remove backup preferences files." | ||
"Location: 0 for local flash, 1 for SD card.", | ||
default=admin_pb2.AdminMessage.BackupLocation.FLASH, | ||
nargs="?", | ||
const=0, | ||
) | ||
|
||
group.add_argument( | ||
"--remove-node", | ||
help="Tell the destination node to remove a specific node from its NodeDB. " | ||
"Use the node ID with a '!' or '0x' prefix or the node number.", | ||
metavar="!xxxxxxxx" | ||
) | ||
|
||
group.add_argument( | ||
"--set-favorite-node", | ||
help="Tell the destination node to set the specified node to be favorited on the NodeDB. " | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "meshtastic" | ||
version = "2.5.12" | ||
version = "2.6.0a1" | ||
description = "Python API & client shell for talking to Meshtastic devices" | ||
authors = ["Meshtastic Developers <[email protected]>"] | ||
license = "GPL-3.0-only" | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be nice if we allow people to pass
FLASH
andSD
here. I think we could do that by trying to parse as an int, and if it fails, throw it at something likeadmin_pb2.AdminMessage.BackupLocation.__getattr__('FLASH')
to convert.I think this could be done by adding a helper function and passing it as
type
to these add_argument calls:I'm a bit tired so hopefully I'm relaying this properly, heh.