summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2021-10-15 15:07:41 +0100
committerMichael Morris <michael.morris@est.tech>2021-10-18 12:13:06 +0000
commit005d5dee8be436246276195067c67ce68d68c2d7 (patch)
treecee8448bd71fa24a17f724de46ea84ea6e7840cc /catalog-be/src/main
parent1b61e72f6506de7c1f64098dd25adf7af7b31dc1 (diff)
Force encoding while reading files in init scripts
To avoid system dependency by using the default encoding, this change sets the encoding when opening files in python scripts to "UTF-8". Change-Id: Ib35f4300f10dea309fcc2967448bd80cad0b335f Issue-ID: SDC-3761 Signed-off-by: André Schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-be/src/main')
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaElements.py2
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaTypes.py2
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/main.py2
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/model_import_manager.py6
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeToUpdateList.py2
-rwxr-xr-xcatalog-be/src/main/resources/scripts/sdcBePy/users/run.py2
6 files changed, 8 insertions, 8 deletions
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaElements.py b/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaElements.py
index 8506207ff9..ef23e3ff6d 100644
--- a/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaElements.py
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaElements.py
@@ -94,7 +94,7 @@ def _create_zip_file_multi_part(element_form_name, type_file_name, element_name)
def _create_json_metadata_str(file_name):
type_metadata_json_file = file_name + ".json"
debug(type_metadata_json_file)
- json_file = open(type_metadata_json_file)
+ json_file = open(type_metadata_json_file, encoding='utf-8')
debug("before load json")
json_data = json.load(json_file, strict=False)
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaTypes.py b/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaTypes.py
index 9304c88b44..9d37c2ad29 100644
--- a/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaTypes.py
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaTypes.py
@@ -94,7 +94,7 @@ def _create_send_body(file_dir, element_name):
debug(path)
current_json_file = file_dir + element_name + "/" + element_name + ".json"
- json_file = open(current_json_file)
+ json_file = open(current_json_file, encoding='utf-8')
debug("before load json")
json_data = json.load(json_file, strict=False)
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/main.py b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/main.py
index 78032a4e3a..b3cf8828ca 100644
--- a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/main.py
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/main.py
@@ -16,7 +16,7 @@ def usage():
def load_be_config(conf_path):
- with open(conf_path, 'r') as f:
+ with open(conf_path, 'r', encoding='utf-8') as f:
return json.load(f)
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/model_import_manager.py b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/model_import_manager.py
index 57ac06d0b2..4cd2d6fde2 100644
--- a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/model_import_manager.py
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/model_import_manager.py
@@ -102,7 +102,7 @@ class ModelImportManager:
def __read_model_payload_as_string(self, model, action_type) -> str:
base_path = self.__get_base_action_path(action_type)
model_payload_path = base_path / model / "payload.json"
- json_file = open(model_payload_path)
+ json_file = open(model_payload_path, encoding='utf-8')
json_data = json.load(json_file, strict=False)
return json.dumps(json_data)
@@ -110,13 +110,13 @@ class ModelImportManager:
path = tosca_path / "types.json"
if not os.path.isfile(path):
return []
- json_file = open(path)
+ json_file = open(path, encoding='utf-8')
return json.load(json_file)
def __read_model_payload(self, model, action_type) -> dict:
base_path = self.__get_base_action_path(action_type)
model_payload_path = base_path / model / "payload.json"
- json_file = open(model_payload_path)
+ json_file = open(model_payload_path, encoding='utf-8')
return json.load(json_file, strict=False)
def __get_base_action_path(self, action_type) -> Path:
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeToUpdateList.py b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeToUpdateList.py
index 6537b1cdd0..ed7fb753e2 100644
--- a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeToUpdateList.py
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/models/normativeToUpdateList.py
@@ -11,7 +11,7 @@ class TypesToUpdate:
def load_files(self, files):
for file in files:
- with open(file, 'r') as stream:
+ with open(file, 'r', encoding='utf-8') as stream:
_types = json.load(stream)
for type_key, type_value in _types.items():
self.types_list[type_key] = type_value
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/users/run.py b/catalog-be/src/main/resources/scripts/sdcBePy/users/run.py
index 56640db4cf..2dbd941cc3 100755
--- a/catalog-be/src/main/resources/scripts/sdcBePy/users/run.py
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/users/run.py
@@ -15,7 +15,7 @@ colors = BColors()
def load_users(conf_path):
- with open(conf_path, 'r') as f:
+ with open(conf_path, 'r', encoding='utf-8') as f:
return json.load(f)