mirror of https://github.com/arendst/Tasmota.git
Merge pull request #4612 from curzon01/development
decode-config.py: Fix `@v` filename template (#4609)
This commit is contained in:
commit
cd2bce9127
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
VER = '2.1.0013'
|
||||
VER = '2.1.0014'
|
||||
|
||||
"""
|
||||
decode-config.py - Backup/Restore Sonoff-Tasmota configuration data
|
||||
|
@ -1178,14 +1178,7 @@ def MakeFilename(filename, filetype, configmapping):
|
|||
if device_hostname is None:
|
||||
device_hostname = ''
|
||||
|
||||
filename = filename.replace('@v', config_version)
|
||||
filename = filename.replace('@f', config_friendlyname )
|
||||
filename = filename.replace('@h', config_hostname )
|
||||
filename = filename.replace('@H', device_hostname )
|
||||
|
||||
|
||||
dirname = basename = ext = ''
|
||||
name = filename
|
||||
|
||||
# split file parts
|
||||
dirname = os.path.normpath(os.path.dirname(filename))
|
||||
|
@ -1217,6 +1210,11 @@ def MakeFilename(filename, filetype, configmapping):
|
|||
except:
|
||||
pass
|
||||
|
||||
filename = filename.replace('@v', config_version)
|
||||
filename = filename.replace('@f', config_friendlyname )
|
||||
filename = filename.replace('@h', config_hostname )
|
||||
filename = filename.replace('@H', device_hostname )
|
||||
|
||||
return filename
|
||||
|
||||
|
||||
|
@ -2371,7 +2369,6 @@ def Backup(backupfile, backupfileformat, encode_cfg, decode_cfg, configmapping):
|
|||
config data mapppings
|
||||
"""
|
||||
|
||||
backupfileformat = args.backupfileformat
|
||||
name, ext = os.path.splitext(backupfile)
|
||||
if ext.lower() == '.'+FileType.BIN.lower():
|
||||
backupfileformat = FileType.BIN
|
||||
|
@ -2434,12 +2431,14 @@ def Backup(backupfile, backupfileformat, encode_cfg, decode_cfg, configmapping):
|
|||
message("Backup successful from {} '{}' to file '{}' ({} format)".format(srctype, src, backup_filename, fileformat), typ=LogType.INFO)
|
||||
|
||||
|
||||
def Restore(restorefile, encode_cfg, decode_cfg, configmapping):
|
||||
def Restore(restorefile, backupfileformat, encode_cfg, decode_cfg, configmapping):
|
||||
"""
|
||||
Restore from file
|
||||
|
||||
@param encode_cfg:
|
||||
binary config data (encrypted)
|
||||
@param backupfileformat:
|
||||
Backup file format
|
||||
@param decode_cfg:
|
||||
binary config data (decrypted)
|
||||
@param configmapping:
|
||||
|
@ -2448,7 +2447,14 @@ def Restore(restorefile, encode_cfg, decode_cfg, configmapping):
|
|||
|
||||
new_encode_cfg = None
|
||||
|
||||
restorefilename = MakeFilename(restorefile, None, configmapping)
|
||||
restorefileformat = None
|
||||
if backupfileformat.lower() == 'bin':
|
||||
restorefileformat = FileType.BIN
|
||||
elif backupfileformat.lower() == 'dmp':
|
||||
restorefileformat = FileType.DMP
|
||||
elif backupfileformat.lower() == 'json':
|
||||
restorefileformat = FileType.JSON
|
||||
restorefilename = MakeFilename(restorefile, restorefileformat, configmapping)
|
||||
filetype = GetFileType(restorefilename)
|
||||
|
||||
if filetype == FileType.DMP:
|
||||
|
@ -2817,7 +2823,7 @@ if __name__ == "__main__":
|
|||
|
||||
# restore from file
|
||||
if args.restorefile is not None:
|
||||
Restore(args.restorefile, encode_cfg, decode_cfg, configmapping)
|
||||
Restore(args.restorefile, args.backupfileformat, encode_cfg, decode_cfg, configmapping)
|
||||
|
||||
# json screen output
|
||||
if (args.backupfile is None and args.restorefile is None) or args.output:
|
||||
|
|
Loading…
Reference in New Issue