anticipate problems with old color schemes; counter with new config

version
This commit is contained in:
Jakob Ketterl 2020-09-17 20:59:16 +02:00
parent fa08f1e2cf
commit 35243fb62e
2 changed files with 15 additions and 5 deletions

View File

@ -33,7 +33,7 @@ config_webrx: configuration options for OpenWebRX
""" """
# configuration version. please only modify if you're able to perform the associated migration steps. # configuration version. please only modify if you're able to perform the associated migration steps.
version = 2 version = 3
# NOTE: you can find additional information about configuring OpenWebRX in the Wiki: # NOTE: you can find additional information about configuring OpenWebRX in the Wiki:
# https://github.com/jketterl/openwebrx/wiki/Configuration-guide # https://github.com/jketterl/openwebrx/wiki/Configuration-guide

View File

@ -49,11 +49,19 @@ class ConfigMigratorVersion1(ConfigMigrator):
return config return config
class ConfigMigratorVersion2(ConfigMigrator):
def migrate(self, config):
if "waterfall_colors" in config and any(v > 0xFFFFFF for v in config["waterfall_colors"]):
config["waterfall_colors"] = [v >> 8 for v in config["waterfall_colors"]]
return config
class Config: class Config:
sharedConfig = None sharedConfig = None
currentVersion = 2 currentVersion = 3
migrators = { migrators = {
1: ConfigMigratorVersion1() 1: ConfigMigratorVersion1(),
2: ConfigMigratorVersion2(),
} }
@staticmethod @staticmethod
@ -130,5 +138,7 @@ class Config:
return config return config
logger.debug("migrating config from version %i", version) logger.debug("migrating config from version %i", version)
migrator = Config.migrators[version] migrators = [Config.migrators[i] for i in range(version, Config.currentVersion)]
return migrator.migrate(config) for migrator in migrators:
config = migrator.migrate(config)
return config