From 099242e8218e527250d8b47bf74301f17ad17439 Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 26 Feb 2025 11:32:44 -0800 Subject: [PATCH] 18423 fix load_yaml / load_json --- netbox/extras/scripts.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/netbox/extras/scripts.py b/netbox/extras/scripts.py index ea8c75df1..b20e7e170 100644 --- a/netbox/extras/scripts.py +++ b/netbox/extras/scripts.py @@ -560,12 +560,6 @@ class BaseScript: # Convenience functions # - def get_storage(self): - if self.storage is None: - self.storage = storages.create_storage(storages.backends["scripts"]) - - return self.storage - def load_yaml(self, filename): """ Return data from a YAML file @@ -575,9 +569,8 @@ class BaseScript: except ImportError: from yaml import Loader - storage = self.get_storage() file_path = os.path.join(settings.SCRIPTS_ROOT, filename) - with storage.open(file_path, 'r') as datafile: + with open(file_path, 'r') as datafile: data = yaml.load(datafile, Loader=Loader) return data @@ -586,10 +579,8 @@ class BaseScript: """ Return data from a JSON file """ - - storage = self.get_storage() file_path = os.path.join(settings.SCRIPTS_ROOT, filename) - with storage.open(file_path, 'r') as datafile: + with open(file_path, 'r') as datafile: data = json.load(datafile) return data