Commit 20f72873 authored by Andrey Vertiprahov's avatar Andrey Vertiprahov
Browse files

Cleanup py3.

parent 2b014936
Pipeline #27486 passed with stages
in 2 minutes and 29 seconds
......@@ -40,3 +40,20 @@ class OrderedDictYAMLLoader(yaml.Loader):
value = self.construct_object(value_node, deep=deep)
mapping[key] = value
return mapping
def ordered_load(stream, Loader=yaml.Loader, object_pairs_hook=OrderedDict):
"""
For Python 3.7+ only
"""
class OrderedLoader(Loader):
pass
def construct_mapping(loader, node):
loader.flatten_mapping(node)
return object_pairs_hook(loader.construct_pairs(node))
OrderedLoader.add_constructor(
yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
construct_mapping)
return yaml.load(stream, OrderedLoader)
......@@ -76,5 +76,5 @@ def migrate(migrator):
if "session_ttl" in config[None]["login"]:
if "d" not in str(config[None]["login"]["session_ttl"]):
config[None]["login"]["session_ttl"] = str(config[None]["login"]["session_ttl"]) + "d"
env.service_config = yaml.dump(config.decode("utf-8"))
env.service_config = yaml.dump(config)
env.save()
......@@ -96,7 +96,7 @@ def migrate(migrator):
"mongod_engine": env.mongo_engine or "wiredTiger",
"mongod_logging_destination": config[None]["mongod"].get("mongod_logging_destination", "file")
}
env.service_config = yaml.dump(config.decode("utf-8"))
env.service_config = yaml.dump(config)
env.save()
migrator.drop_column(
......
......@@ -158,5 +158,5 @@ def migrate(migrator):
config[None]["telegraf"] = {
"telegraf_output_plugin": "influx"
}
env.service_config = yaml.dump(config.decode("utf-8"))
env.service_config = yaml.dump(config)
env.save()
......@@ -61,7 +61,7 @@ def migrate(migrator):
"cert": pub_key,
"cert_key": priv_key
}
env.service_config = yaml.dump(config.decode("utf-8"))
env.service_config = yaml.dump(config)
env.save()
migrator.drop_column(
......
......@@ -66,7 +66,7 @@ def migrate(migrator):
for pool in config:
for srv in config[pool]:
cfg = config[pool][srv]
q = Service.update(config=json.dumps(cfg.decode("utf-8"), sort_keys=True)).where(
q = Service.update(config=json.dumps(cfg, sort_keys=True)).where(
Service.environment == env.id,
Service.service == srv,
Service.pool == pool
......
......@@ -246,7 +246,7 @@ def migrate(migrator):
if 'logging' in conf:
del conf['logging']
conf["loglevel"] = srv.loglevel
srv.config = json.dumps(conf.decode("utf-8"), sort_keys=True)
srv.config = json.dumps(conf, sort_keys=True)
srv.save()
# noc service should be enabled if any noc services was enabled
for n in noc_promote_nodes:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment