From 8c434cbc7995c3a5b948233d848fa8a7bb7bc0e3 Mon Sep 17 00:00:00 2001 From: EKbfh Date: Thu, 5 Mar 2020 22:01:30 +0300 Subject: [PATCH] Fix yaml.load() according to https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation --- tower/api/service.py | 2 +- tower/migrations/024_change_session_timeout.py | 2 +- tower/migrations/030_move_db_settings.py | 2 +- tower/migrations/032_add_default_roles.py | 2 +- tower/migrations/033_remove_custom.py | 2 +- tower/migrations/034_service_config.py | 2 +- tower/models/environment.py | 2 +- tower/models/service.py | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tower/api/service.py b/tower/api/service.py index e9d2faf6..3403b4bd 100644 --- a/tower/api/service.py +++ b/tower/api/service.py @@ -34,7 +34,7 @@ class ServiceAPI(API): if not os.path.exists(path): continue with open(path) as f: - descr = yaml.load(f, OrderedDictYAMLLoader) + descr = yaml.full_load(f, OrderedDictYAMLLoader) if not descr: continue if "services" not in descr or not descr["services"]: diff --git a/tower/migrations/024_change_session_timeout.py b/tower/migrations/024_change_session_timeout.py index 2c725802..a02b4912 100644 --- a/tower/migrations/024_change_session_timeout.py +++ b/tower/migrations/024_change_session_timeout.py @@ -71,7 +71,7 @@ def migrate(migrator): is_default = BooleanField(default=False) for env in Environment.select(): - config = yaml.load(env.service_config) + config = yaml.full_load(env.service_config) 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" diff --git a/tower/migrations/030_move_db_settings.py b/tower/migrations/030_move_db_settings.py index 04723503..eba7aedb 100644 --- a/tower/migrations/030_move_db_settings.py +++ b/tower/migrations/030_move_db_settings.py @@ -73,7 +73,7 @@ def migrate(migrator): if len(Environment.select()) != 0: for env in Environment.select(): print("Migrating %s" % env.name) - config = yaml.load(env.service_config) + config = yaml.full_load(env.service_config) if not config: continue config[None]["influxdb"] = { diff --git a/tower/migrations/032_add_default_roles.py b/tower/migrations/032_add_default_roles.py index d23f3e6a..733dc16b 100644 --- a/tower/migrations/032_add_default_roles.py +++ b/tower/migrations/032_add_default_roles.py @@ -152,7 +152,7 @@ def migrate(migrator): loglevel="info" ).save() # Adjust service config - config = yaml.load(env.service_config) or {None: {}} + config = yaml.full_load(env.service_config) or {None: {}} config[None]["telegraf"] = { "telegraf_output_plugin": "influx" } diff --git a/tower/migrations/033_remove_custom.py b/tower/migrations/033_remove_custom.py index e275f248..5d0768ca 100644 --- a/tower/migrations/033_remove_custom.py +++ b/tower/migrations/033_remove_custom.py @@ -35,7 +35,7 @@ def migrate(migrator): if len(Environment.select()) != 0: for env in Environment.select(): print("Migrating %s" % env.name) - config = yaml.load(env.service_config) + config = yaml.full_load(env.service_config) if not config: continue if env.custom_repo: diff --git a/tower/migrations/034_service_config.py b/tower/migrations/034_service_config.py index 29e4a115..2b256343 100644 --- a/tower/migrations/034_service_config.py +++ b/tower/migrations/034_service_config.py @@ -58,7 +58,7 @@ def migrate(migrator): print("Migrating %s" % env.name) # remove nodes without services - config = yaml.load(env.service_config) + config = yaml.full_load(env.service_config) if not config: continue # move settings from environment to service diff --git a/tower/models/environment.py b/tower/models/environment.py index 87520559..52458b34 100644 --- a/tower/models/environment.py +++ b/tower/models/environment.py @@ -415,7 +415,7 @@ class Environment(Model): if not os.path.exists(path): continue with open(path) as f: - descr = yaml.load(f) + descr = yaml.full_load(f) if not descr: continue if "services" not in descr or not descr["services"]: diff --git a/tower/models/service.py b/tower/models/service.py index b422438d..5aca41d9 100644 --- a/tower/models/service.py +++ b/tower/models/service.py @@ -45,7 +45,7 @@ class Service(Model): if not os.path.exists(path): continue with open(path) as f: - descr = yaml.load(f) + descr = yaml.full_load(f) if not descr: continue for srv in sorted(descr["services"]): -- GitLab