holado 0.8.1__py3-none-any.whl → 0.8.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of holado might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: holado
3
- Version: 0.8.1
3
+ Version: 0.8.2
4
4
  Summary: HolAdo framework
5
5
  Project-URL: Homepage, https://gitlab.com/holado_framework/python
6
6
  Project-URL: Issues, https://gitlab.com/holado_framework/python/-/issues
@@ -194,7 +194,7 @@ holado_docker/sdk/docker/docker_service.py,sha256=SvMSIZ7XTCbC7q5rur03lJhJVSHL3u
194
194
  holado_docker/tests/behave/steps/__init__.py,sha256=lrP0btKLA3qQD2wp3zbOp0ug8RmgpaYWCrOAWehcPiI,1298
195
195
  holado_docker/tests/behave/steps/tools/docker_controller/client_steps.py,sha256=Y26ZstOZrI3uVX6MGBQr88jjDEsCsNuik0ZBmpT5kDg,4800
196
196
  holado_docker/tools/docker_controller/docker_controller_manager.py,sha256=q3oac2KIK9wGfMQqGIol65nHUmeuuV0rQ61tfH2APAk,2477
197
- holado_docker/tools/docker_controller/client/rest/docker_controller_client.py,sha256=TP3GBgtZusl9y6mNd8rFsOoF9K7u_M8mLFq3ZTsCHUM,4316
197
+ holado_docker/tools/docker_controller/client/rest/docker_controller_client.py,sha256=rySX7cK-SBfYRLnspntm8tWuDVyHEGuxFs9vJm7wHDA,4316
198
198
  holado_docker/tools/docker_controller/server/Dockerfile,sha256=zuSkj3HYDhvpjOSXmxL4oDqhN7dRB1YTX5Fyur1cuDY,1774
199
199
  holado_docker/tools/docker_controller/server/requirements.txt,sha256=0RvLV3t2DyBR2FsbAd1WVEcbsVc6FVUN2horQJU4POo,57
200
200
  holado_docker/tools/docker_controller/server/run_docker_controller_in_docker.sh,sha256=Q56P8VA895I29kVSaSa2FpzvjxJUwLVZ9-7vjScXfc0,3406
@@ -207,7 +207,7 @@ holado_docker/tools/docker_controller/server/rest/initialize_holado.py,sha256=Ux
207
207
  holado_docker/tools/docker_controller/server/rest/openapi.yaml,sha256=HUD7CHasVGjpd6yW9mU0sWOKs4tuG_VSoefa7NuQWFI,6773
208
208
  holado_docker/tools/docker_controller/server/rest/run.py,sha256=8w5Xl7uOnjsYW59cmuUMOUd71fcXQn30k2jVis7cVNs,1748
209
209
  holado_docker/tools/docker_controller/server/rest/api/__init__.py,sha256=FlLRagAiw1LDxnF0CmW7Y6bVXuj8x6volT8-DuHTTVY,2427
210
- holado_docker/tools/docker_controller/server/rest/api/config.py,sha256=pe76IMkdNoljRsDRyhZW6BwkSSu6LsvnSEGqgd8_Ro4,2459
210
+ holado_docker/tools/docker_controller/server/rest/api/config.py,sha256=Ln__1bsigSzJZ-Iy3MQgmiZMnpBxC3TCQE0O72g5cAs,2459
211
211
  holado_docker/tools/docker_controller/server/rest/api/container.py,sha256=6D612WF4chpDCzr4MBzZXzELxi-yOwrgxCxSBBVMcVo,2673
212
212
  holado_docker/tools/docker_controller/server/rest/api/os.py,sha256=ZdAbx_ZzwMaqHseOWWSf9ZPL_CEdRa2RvEXGvkk5c1o,1830
213
213
  holado_docker/tools/docker_viewer/docker_viewer_manager.py,sha256=tSLuIUdYjJoZIFUc1k4WnrRTUtjjTAmNTbrDmS-8SjI,2287
@@ -480,10 +480,10 @@ holado_system/system/command/command.py,sha256=9lv9kgvvIq4Fqx6fJXU_HQA8pCO80Ws9r
480
480
  holado_system/system/command/command_result.py,sha256=sunGDegNVOtpK9s9r4HCAJlREu4iKS0w3HY4KKDEQkw,4613
481
481
  holado_system/system/command/curl_command.py,sha256=CEMaO0_qLyKe4tLytMlHzmCuS_gi-oU479hwOaEyZ60,3743
482
482
  holado_system/system/command/exceptions.py,sha256=InT6t8GVeGCiBE-NpRr4NzycWVAvzmc6WpM6mk7_1yk,2363
483
- holado_system/system/filesystem/file.py,sha256=Y5uq2n-ttimdRvLh3QQjpECoOSUzcj9DesuT2HerYuk,2840
483
+ holado_system/system/filesystem/file.py,sha256=stIFMNPeJuQNYlrm-wQPdwnRP8SgLoah7hkjz0hvx5g,4084
484
484
  holado_system/tests/behave/steps/__init__.py,sha256=7LrCSTHk5oHNuEsr4IhJuNDsohtR2cq3YT1owXrhdjc,1351
485
485
  holado_system/tests/behave/steps/system/commands_steps.py,sha256=uYiojPpYPkfif8l8afRrJ0sj-wFBE4j1x67BDMNs76Q,3901
486
- holado_system/tests/behave/steps/system/file_steps.py,sha256=kJ7qEzaKkzErRpWCWmq1mJhqO3kHlMa-u5RmsG4664g,10388
486
+ holado_system/tests/behave/steps/system/file_steps.py,sha256=-RPUGEjsYfzWIMRDiQRalmvspPZIPP8YMzSZvSI4-p8,9966
487
487
  holado_system/tests/behave/steps/system/system_steps.py,sha256=2XrZwuAaYDjB_HvPgxZq9MpYB_Zo7FVZ0DYcmtKht2s,3778
488
488
  holado_test/__init__.py,sha256=A0edMOLhnuU-A_NazQ50WghvKvB889KNCBddtBPa9Ag,1539
489
489
  holado_test/test_config.py,sha256=yQK2jNHEGltGc3fmsAgcsKN4y3_nuldZHD45XEMrsQA,1575
@@ -529,7 +529,7 @@ holado_yaml/__init__.py,sha256=KpbIi2cm1BYZgoWf0LuhE0ei3ZCE15UcUtjC1cSA55M,1653
529
529
  holado_yaml/tests/behave/steps/__init__.py,sha256=mXzHzGy9gkIDjYXdlxQ6BzaT4AfithgRmL_1sMxr63g,1272
530
530
  holado_yaml/tests/behave/steps/yaml_steps.py,sha256=cxNgDywCopT_RCeqKiWfcJYyKZM3mlc39bAtGm2rgfc,8531
531
531
  holado_yaml/yaml/enums.py,sha256=WD7mM_VhXtv8l0n08s6CSe7k2RUZDf_70mNCFsjjo94,1625
532
- holado_yaml/yaml/yaml_client.py,sha256=I7Xkhk0KIBVucEBNzTN2vWNOjuSQ-7W_D8ZiPHl1M7k,9042
532
+ holado_yaml/yaml/yaml_client.py,sha256=sg0UEBD33MqiY-8CxlZT4mT_blkp5Z926vvQjkhiNFA,9288
533
533
  holado_yaml/yaml/yaml_manager.py,sha256=iAg-WyXgHeIq_7WzYiVYE8G19Mcalqie8cD3_eyxogg,4363
534
534
  holado_yaml/yaml/pyyaml/pyyaml_client.py,sha256=yZrx42Y3fGt6psBsLXTzMTWH30oiOfzsm5dVPkpJjQE,3086
535
535
  holado_yaml/yaml/ruamel/ruamel_yaml_client.py,sha256=i4fJi-gbKJMfUPd3KfJPFaF7ZP6shMNfCPu8NPhAJVg,3201
@@ -655,7 +655,7 @@ test_holado/tools/django/api_rest/api_rest/api1/serializers.py,sha256=o_YxFr-tgC
655
655
  test_holado/tools/django/api_rest/api_rest/api1/tests.py,sha256=mrbGGRNg5jwbTJtWWa7zSKdDyeB4vmgZCRc2nk6VY-g,60
656
656
  test_holado/tools/django/api_rest/api_rest/api1/views.py,sha256=kOt2xT6bxO47_z__5yYR9kcYIWWv4qYzpX0K8Tqonik,758
657
657
  test_holado/tools/django/api_rest/api_rest/api1/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
658
- holado-0.8.1.dist-info/METADATA,sha256=96tNajEz2ibDQX0118wv3VNay6ndeo-YNIOGQvMo2bI,7671
659
- holado-0.8.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
660
- holado-0.8.1.dist-info/licenses/LICENSE,sha256=IgGmNlcFHnbp7UWrLJqAFvs_HIgjJDTmjCNRircJLsk,1070
661
- holado-0.8.1.dist-info/RECORD,,
658
+ holado-0.8.2.dist-info/METADATA,sha256=zWwgnlMfG4-_3ABtoVtk1fIB0DZNXW9Uq2qPI-2snwU,7671
659
+ holado-0.8.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
660
+ holado-0.8.2.dist-info/licenses/LICENSE,sha256=IgGmNlcFHnbp7UWrLJqAFvs_HIgjJDTmjCNRircJLsk,1070
661
+ holado-0.8.2.dist-info/RECORD,,
@@ -26,12 +26,12 @@ class DockerControllerClient(RestClient):
26
26
 
27
27
  def get_environment_variable_value(self, var_name):
28
28
  data = [var_name]
29
- response = self.get(f"os/env", data=data)
29
+ response = self.get(f"os/env", json=data)
30
30
  return self.response_result(response, status_ok=[200])
31
31
 
32
32
  def get_directory_filenames(self, path):
33
33
  data = {'path':path}
34
- response = self.get(f"os/ls", data=data)
34
+ response = self.get(f"os/ls", json=data)
35
35
  return self.response_result(response, status_ok=[200])
36
36
 
37
37
 
@@ -86,7 +86,7 @@ class DockerControllerClient(RestClient):
86
86
  'with_backup': with_backup,
87
87
  'backup_extension': backup_extension
88
88
  }
89
- response = self.patch(f"config/yaml_file", data=data)
89
+ response = self.patch(f"config/yaml_file", json=data)
90
90
  return self.response_result(response, status_ok=[200,204])
91
91
 
92
92
  def restore_yaml_file(self, file_path, backup_extension='.ha_bak'):
@@ -95,7 +95,7 @@ class DockerControllerClient(RestClient):
95
95
  'file_path': file_path,
96
96
  'backup_extension': backup_extension
97
97
  }
98
- response = self.put(f"config/yaml_file", data=data)
98
+ response = self.put(f"config/yaml_file", json=data)
99
99
  return self.response_result(response, status_ok=[200,204])
100
100
 
101
101
 
@@ -18,7 +18,7 @@ def _get_session_context():
18
18
  return SessionContext.instance()
19
19
 
20
20
 
21
- class YamlfileView(MethodView):
21
+ class YamlFileView(MethodView):
22
22
 
23
23
  def get(self, body: dict):
24
24
  file_path = body['file_path']
@@ -14,6 +14,8 @@
14
14
  from holado.common.handlers.object import DeleteableObject
15
15
  import os
16
16
  from typing import AnyStr, List
17
+ from holado_python.standard_library.typing import Typing
18
+ from holado_core.common.exceptions.technical_exception import TechnicalException
17
19
 
18
20
 
19
21
  class File(DeleteableObject):
@@ -33,7 +35,15 @@ class File(DeleteableObject):
33
35
 
34
36
  def _delete_object(self):
35
37
  self.close()
36
-
38
+
39
+ def __enter__(self):
40
+ if self.__file is None:
41
+ self.open()
42
+ return self
43
+
44
+ def __exit__(self, exc_type, exc_val, exc_tb):
45
+ self.close()
46
+
37
47
  @property
38
48
  def path(self):
39
49
  return self.__path
@@ -74,3 +84,36 @@ class File(DeleteableObject):
74
84
  def readlines(self, hint: int = -1) -> List[AnyStr]:
75
85
  return self.internal_file.readlines(hint)
76
86
 
87
+
88
+
89
+ @classmethod
90
+ def get_file_content(cls, path, is_text_file=True):
91
+ mode = 'rt' if is_text_file else 'rb'
92
+ with File(path, mode=mode) as file:
93
+ res = file.read()
94
+ return res
95
+
96
+ @classmethod
97
+ def get_file_content_in_base64(cls, path):
98
+ import base64
99
+
100
+ with File(path, mode="rb") as fin:
101
+ content = fin.read()
102
+ res = base64.b64encode(content)
103
+
104
+ return res
105
+
106
+ @classmethod
107
+ def create_file_with_content(cls, path, content):
108
+ if isinstance(content, str):
109
+ with File(path, mode='wt') as fout:
110
+ fout.write(content)
111
+ elif isinstance(content, bytes):
112
+ with File(path, mode='wb') as fout:
113
+ fout.write(content)
114
+ else:
115
+ raise TechnicalException(f"Unexpected content type {Typing.get_object_class_fullname(content)} (allowed types: str, bytes)")
116
+
117
+
118
+
119
+
@@ -88,8 +88,7 @@ def step_impl(context, var_name, path):
88
88
  open_kwargs = ValueTableConverter.convert_name_value_table_2_dict(table)
89
89
 
90
90
  __get_path_manager().makedirs(path)
91
- res = File(path)
92
- res.open(**open_kwargs)
91
+ res = File(path, **open_kwargs)
93
92
 
94
93
  __get_variable_manager().register_variable(var_name, res)
95
94
 
@@ -125,9 +124,7 @@ def step_impl(context, var_name, is_text_file_str, path): # @DuplicatedSignatur
125
124
  is_text_file = is_text_file_str is not None
126
125
  path = StepTools.evaluate_scenario_parameter(path)
127
126
 
128
- mode = 'rt' if is_text_file else 'rb'
129
- with open(path, mode) as fin:
130
- res = fin.read()
127
+ res = File.get_file_content(path, is_text_file)
131
128
 
132
129
  __get_variable_manager().register_variable(var_name, res)
133
130
 
@@ -136,9 +133,7 @@ def step_impl(context, var_name, path): # @DuplicatedSignature
136
133
  var_name = StepTools.evaluate_variable_name(var_name)
137
134
  path = StepTools.evaluate_scenario_parameter(path)
138
135
 
139
- with open(path, "rb") as fin:
140
- content = fin.read()
141
- res = base64.b64encode(content)
136
+ res = File.get_file_content_in_base64(path)
142
137
 
143
138
  __get_variable_manager().register_variable(var_name, res)
144
139
 
@@ -147,7 +142,7 @@ def step_impl(context, var_name, path): # @DuplicatedSignature
147
142
  var_name = StepTools.evaluate_variable_name(var_name)
148
143
  path = StepTools.evaluate_scenario_parameter(path)
149
144
 
150
- with open(path, "r") as fin:
145
+ with File(path, mode="r") as fin:
151
146
  lines = fin.readlines()
152
147
  res = list(map(lambda x: x.strip('\n'), lines))
153
148
 
@@ -192,14 +187,7 @@ def step_impl(context, var_name, path_name, content):
192
187
  file_path = os.path.join(dest_path, filename)
193
188
  __get_path_manager().makedirs(file_path)
194
189
 
195
- if isinstance(content, str):
196
- with open(file_path, 'wt') as fout:
197
- fout.write(content)
198
- elif isinstance(content, bytes):
199
- with open(file_path, 'wb') as fout:
200
- fout.write(content)
201
- else:
202
- raise TechnicalException(f"Unexpected content type {Typing.get_object_class_fullname(content)} (allowed types: string, bytes)")
190
+ File.create_file_with_content(file_path, content)
203
191
 
204
192
  __get_variable_manager().register_variable(var_name, file_path)
205
193
 
@@ -104,16 +104,24 @@ class YAMLClient(Object):
104
104
 
105
105
  # Update file
106
106
  dst_data = self.load_file(file_path)
107
- self.update_data(dst_data, data, update_type)
107
+ if dst_data is None:
108
+ dst_data = data
109
+ else:
110
+ self.update_data(dst_data, data, update_type)
108
111
  self.save_in_file(file_path, dst_data, **kwargs) # Note: as file already exists, it is not needed to pass parameters mode, user and group
109
112
 
110
113
  def update_string(self, text, data, update_type=UpdateType.AddOrUpdate, **kwargs):
111
114
  dst_data = self.load_string(text)
112
- self.update_data(dst_data, data, update_type)
115
+ if dst_data is None:
116
+ dst_data = data
117
+ else:
118
+ self.update_data(dst_data, data, update_type)
113
119
  res = self.save_in_string(dst_data, **kwargs)
114
120
  return res
115
121
 
116
122
  def update_data(self, dst, src, update_type=UpdateType.AddOrUpdate):
123
+ if dst is None:
124
+ raise TechnicalException("Destination data cannot be None")
117
125
  if isinstance(src, str):
118
126
  src = self.load_string(src)
119
127
 
File without changes