fix #291: give backups a default name that includes a timestamp

this prevents backups from being overwritten by accident.
This commit is contained in:
bunnie 2023-01-05 14:26:43 +08:00
parent bb5d7b3adf
commit 7b2bfcb247

View file

@ -10,7 +10,6 @@ import hashlib
import csv
import urllib.request
from datetime import datetime
from datetime import date
from Crypto.Hash import SHA512
from progressbar.bar import ProgressBar
@ -558,10 +557,15 @@ def main():
"--peek", required=False, help="Inspect an address", type=auto_int, metavar=('ADDR')
)
parser.add_argument(
"--output", help="Output file name", type=str, default="backup.pddb"
"--output", help="Output file name. Defaults to ./backup_<current_iso_time>.pddb", type=str, default=None
)
args = parser.parse_args()
if args.output is None:
ofile = "backup_{}.pddb".format(datetime.now().isoformat())
else:
ofile = args.output
dev = usb.core.find(idProduct=0x5bf0, idVendor=0x1209)
if dev is None:
@ -627,7 +631,7 @@ def main():
if args.peek:
pc_usb.peek(args.peek + flash_region, display=True)
else:
with open(args.output, "wb") as file:
with open(ofile, "wb") as file:
checksum = []
start_addr = locs['LOC_PDDB'][0] - 0x1000
total_length = locs['LOC_WF200'][0] - locs['LOC_PDDB'][0] + 0x1000