psr-factory 4.1.0b3__py3-none-win_amd64.whl → 4.1.0b5__py3-none-win_amd64.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.
- psr/cloud/cloud.py +63 -25
- psr/cloud/version.py +1 -1
- psr/factory/__init__.py +1 -1
- psr/factory/api.py +86 -21
- psr/factory/factory.dll +0 -0
- psr/factory/factory.pmd +97 -74
- psr/factory/factory.pmk +511 -49
- psr/factory/factorylib.py +6 -0
- psr/factory/libcurl-x64.dll +0 -0
- {psr_factory-4.1.0b3.dist-info → psr_factory-4.1.0b5.dist-info}/METADATA +3 -3
- {psr_factory-4.1.0b3.dist-info → psr_factory-4.1.0b5.dist-info}/RECORD +14 -14
- {psr_factory-4.1.0b3.dist-info → psr_factory-4.1.0b5.dist-info}/WHEEL +1 -1
- {psr_factory-4.1.0b3.dist-info → psr_factory-4.1.0b5.dist-info}/licenses/LICENSE.txt +0 -0
- {psr_factory-4.1.0b3.dist-info → psr_factory-4.1.0b5.dist-info}/top_level.txt +0 -0
psr/cloud/cloud.py
CHANGED
@@ -68,12 +68,8 @@ def _check_for_errors(
|
|
68
68
|
|
69
69
|
|
70
70
|
def _hide_password(params: str) -> str:
|
71
|
-
# Define a expressão regular para encontrar o parâmetro senha com atributos adicionais
|
72
71
|
pattern = r'(<Parametro nome="senha"[^>]*>)(.*?)(</Parametro>)'
|
73
|
-
|
74
|
-
# Substitui o conteúdo da senha por ********
|
75
72
|
result = re.sub(pattern, r"\1********\3", params)
|
76
|
-
|
77
73
|
return result
|
78
74
|
|
79
75
|
|
@@ -328,7 +324,7 @@ class Client:
|
|
328
324
|
_hide_password(xml_content)
|
329
325
|
raise CloudInputError(
|
330
326
|
f"Invalid XML content.\n"
|
331
|
-
f"Contact PSR support with following data:\n\n{xml_content}\n\
|
327
|
+
f"Contact PSR support at psrcloud@psr-inc.com with following data:\n\n{xml_content}\n\n"
|
332
328
|
)
|
333
329
|
|
334
330
|
def _get_clusters_by_user(self) -> list:
|
@@ -631,7 +627,7 @@ class Client:
|
|
631
627
|
xml_str = _xml_to_str(xml)
|
632
628
|
raise CloudError(
|
633
629
|
f"Case id not found on returned XML response.\n"
|
634
|
-
f"Contact PSR support with following data:\n\n{xml_str}\n\
|
630
|
+
f"Contact PSR support at psrcloud@psr-inc.com with following data:\n\n{xml_str}\n\n"
|
635
631
|
)
|
636
632
|
|
637
633
|
case_id = int(id_parameter.text)
|
@@ -679,7 +675,7 @@ class Client:
|
|
679
675
|
xml_str = _xml_to_str(xml)
|
680
676
|
raise CloudError(
|
681
677
|
f"Status not found on returned XML response.\n"
|
682
|
-
f"Contact PSR support with following data:\n\n{xml_str}\n\
|
678
|
+
f"Contact PSR support at psrcloud@psr-inc.com with following data:\n\n{xml_str}\n\n"
|
683
679
|
)
|
684
680
|
try:
|
685
681
|
status = ExecutionStatus(int(parameter_status.text))
|
@@ -687,12 +683,35 @@ class Client:
|
|
687
683
|
xml_str = _xml_to_str(xml)
|
688
684
|
raise CloudError(
|
689
685
|
f"Unrecognized status on returned XML response.\n"
|
690
|
-
f"Contact PSR support with following data:\n\n{xml_str}\n\
|
686
|
+
f"Contact PSR support at psrcloud@psr-inc.com with following data:\n\n{xml_str}\n\n"
|
691
687
|
)
|
692
688
|
|
693
689
|
self._logger.info(f"Status: {STATUS_MAP_TEXT[status]}")
|
694
690
|
return status, STATUS_MAP_TEXT[status]
|
695
691
|
|
692
|
+
def list_download_files(self, case_id: int) -> List[str]:
|
693
|
+
xml_files = self._make_soap_request(
|
694
|
+
"prepararListaArquivosRemotaDownload",
|
695
|
+
"listaArquivoRemota",
|
696
|
+
additional_arguments={
|
697
|
+
"cluster": self.cluster["name"],
|
698
|
+
"filtro": "(.*)",
|
699
|
+
"diretorioRemoto": str(case_id),
|
700
|
+
},
|
701
|
+
)
|
702
|
+
|
703
|
+
files = []
|
704
|
+
|
705
|
+
for file in xml_files.findall("Arquivo"):
|
706
|
+
file_info = {
|
707
|
+
"name": file.attrib.get("nome"),
|
708
|
+
"filesize": file.attrib.get("filesize"),
|
709
|
+
"filedate": file.attrib.get("filedate"),
|
710
|
+
}
|
711
|
+
files.append(file_info)
|
712
|
+
|
713
|
+
return files
|
714
|
+
|
696
715
|
def download_results(
|
697
716
|
self,
|
698
717
|
case_id: int,
|
@@ -816,7 +835,9 @@ class Client:
|
|
816
835
|
initial_date_iso = since.strftime("%Y-%m-%d %H:%M:%S")
|
817
836
|
|
818
837
|
xml = self._make_soap_request(
|
819
|
-
"listarFila",
|
838
|
+
"listarFila",
|
839
|
+
"dados",
|
840
|
+
additional_arguments={"dataInicial": initial_date_iso},
|
820
841
|
)
|
821
842
|
|
822
843
|
return self._cases_from_xml(xml)
|
@@ -830,7 +851,9 @@ class Client:
|
|
830
851
|
def get_cases(self, case_ids: List[int]) -> List["Case"]:
|
831
852
|
case_ids_str = ",".join(map(str, case_ids))
|
832
853
|
xml = self._make_soap_request(
|
833
|
-
"listarFila",
|
854
|
+
"listarFila",
|
855
|
+
"dados",
|
856
|
+
additional_arguments={"listaRepositorio": case_ids_str},
|
834
857
|
)
|
835
858
|
return self._cases_from_xml(xml)
|
836
859
|
|
@@ -851,18 +874,29 @@ class Client:
|
|
851
874
|
budgets.sort()
|
852
875
|
return budgets
|
853
876
|
|
854
|
-
def _make_soap_request(self, service: str,
|
877
|
+
def _make_soap_request(self, service: str, name: str = "", **kwargs) -> ET.Element:
|
855
878
|
portal_ws = zeep.Client(self.cluster["url"] + "?WSDL")
|
856
879
|
section = str(id(self))
|
857
880
|
password_md5 = _md5sum(self.username + self.__password + section).upper()
|
858
|
-
|
881
|
+
password_md5 = (
|
882
|
+
password_md5
|
883
|
+
if self.cluster["name"] == "PSR-US"
|
884
|
+
or self.cluster["name"] == "PSR-HOTFIX"
|
885
|
+
or self.cluster["name"] == "PSR-US_OHIO"
|
886
|
+
else self.__password.upper()
|
887
|
+
)
|
888
|
+
additional_arguments = kwargs.get("additional_arguments", None)
|
859
889
|
parameters = {
|
860
890
|
"sessao_id": section,
|
861
|
-
"tipo_autenticacao": "portal"
|
891
|
+
"tipo_autenticacao": "portal"
|
892
|
+
if self.cluster["name"] == "PSR-US"
|
893
|
+
or self.cluster["name"] == "PSR-HOTFIX"
|
894
|
+
or self.cluster["name"] == "PSR-US_OHIO"
|
895
|
+
else "bcrypt",
|
862
896
|
"idioma": "3",
|
863
897
|
}
|
864
|
-
if
|
865
|
-
parameters.update(
|
898
|
+
if additional_arguments:
|
899
|
+
parameters.update(additional_arguments)
|
866
900
|
|
867
901
|
# FIXME make additional arguments work as a dictionary to work with this code
|
868
902
|
xml_input = create_case_xml(parameters)
|
@@ -871,22 +905,26 @@ class Client:
|
|
871
905
|
xml_output_str = portal_ws.service.despacharServico(
|
872
906
|
service, self.username, password_md5, xml_input
|
873
907
|
)
|
874
|
-
except zeep.exceptions.Fault:
|
908
|
+
except zeep.exceptions.Fault as e:
|
909
|
+
# Log the full exception details
|
910
|
+
self._logger.error(f"Zeep Fault: {str(e)}")
|
875
911
|
raise CloudError(
|
876
|
-
"Failed to connect to PSR Cloud service. Contact PSR support:
|
912
|
+
"Failed to connect to PSR Cloud service. Contact PSR support: psrcloud@psr-inc.com"
|
877
913
|
)
|
878
|
-
|
879
914
|
# Remove control characters - this is a thing
|
880
915
|
xml_output_str = xml_output_str.replace("&#x1F;", "")
|
881
916
|
|
882
917
|
xml_output = ET.fromstring(xml_output_str)
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
918
|
+
|
919
|
+
if name:
|
920
|
+
for child in xml_output:
|
921
|
+
if child.attrib.get("nome") == name:
|
922
|
+
xml_output = ET.fromstring(child.text)
|
923
|
+
break
|
924
|
+
else:
|
925
|
+
raise ValueError(
|
926
|
+
f"Invalid XML response from PSR Cloud: {xml_output_str}. Please contact PSR support at psrcloud@psr-inc.com"
|
927
|
+
)
|
890
928
|
return xml_output
|
891
929
|
|
892
930
|
def _get_cloud_versions_xml(self) -> ET.Element:
|
psr/cloud/version.py
CHANGED
psr/factory/__init__.py
CHANGED
psr/factory/api.py
CHANGED
@@ -257,6 +257,23 @@ def _get_context(models_or_context: Union[str, list, dict, "Context", None],
|
|
257
257
|
value.set(context)
|
258
258
|
return value
|
259
259
|
|
260
|
+
def _get_arg_object(arg: Union[dict, "Value", "DataObject", None]) -> "Value":
|
261
|
+
if isinstance(arg, dict):
|
262
|
+
value = Value()
|
263
|
+
value.set(arg)
|
264
|
+
return value
|
265
|
+
elif isinstance(arg, Value):
|
266
|
+
return arg
|
267
|
+
elif isinstance(arg, DataObject):
|
268
|
+
value = Value()
|
269
|
+
value.set(arg)
|
270
|
+
return value
|
271
|
+
elif arg is None:
|
272
|
+
return Value()
|
273
|
+
else:
|
274
|
+
raise TypeError("Unexpected type for argument.")
|
275
|
+
|
276
|
+
|
260
277
|
|
261
278
|
class _BaseObject:
|
262
279
|
def __init__(self):
|
@@ -545,6 +562,7 @@ class ValueDict(_BaseObject):
|
|
545
562
|
class Value(_BaseObject):
|
546
563
|
def __init__(self):
|
547
564
|
super().__init__()
|
565
|
+
_check_loaded()
|
548
566
|
self._hdr = factorylib.lib.psrd_new_value()
|
549
567
|
|
550
568
|
def __del__(self):
|
@@ -1270,36 +1288,51 @@ class Study(_BaseObject):
|
|
1270
1288
|
|
1271
1289
|
@staticmethod
|
1272
1290
|
def load(study_path: Union[str, pathlib.Path], profile_or_context: Union[str, Context, None],
|
1273
|
-
|
1291
|
+
settings_only: bool = False,
|
1292
|
+
options: Optional[Union[dict, "Value", "DataObject"]] = None):
|
1274
1293
|
if not isinstance(options, (DataObject, type(None))):
|
1275
1294
|
raise TypeError("options must be a DataObject or None.")
|
1295
|
+
_check_initialized()
|
1276
1296
|
study_path = str(study_path)
|
1277
1297
|
context = _get_context(profile_or_context, None)
|
1278
1298
|
err = Error()
|
1279
|
-
|
1299
|
+
options_value = _get_arg_object(options)
|
1280
1300
|
study = Study()
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1301
|
+
if not settings_only:
|
1302
|
+
load_fn = factorylib.lib.psrd_study_load
|
1303
|
+
else:
|
1304
|
+
load_fn = factorylib.lib.psrd_study_load_settings
|
1305
|
+
study._hdr = load_fn(_c_str(study_path), _bytes(study_path),
|
1306
|
+
options_value.handler(), context.handler(),
|
1307
|
+
err.handler())
|
1286
1308
|
if err.code != 0:
|
1287
1309
|
raise FactoryException(err.what)
|
1288
1310
|
return study
|
1289
1311
|
|
1290
|
-
def save(self, output_path: Union[str, pathlib.Path],
|
1291
|
-
|
1292
|
-
raise TypeError("options must be a DataObject or None.")
|
1312
|
+
def save(self, output_path: Union[str, pathlib.Path],
|
1313
|
+
options: Optional[Union[dict, Value, DataObject]] = None):
|
1293
1314
|
output_path = str(output_path)
|
1294
1315
|
_err = Error()
|
1295
|
-
|
1296
|
-
factorylib.lib.psrd_study_save(self._hdr,
|
1297
|
-
_bytes(output_path),
|
1298
|
-
|
1316
|
+
options_value = _get_arg_object(options)
|
1317
|
+
factorylib.lib.psrd_study_save(self._hdr,
|
1318
|
+
_c_str(output_path), _bytes(output_path),
|
1319
|
+
options_value.handler(),
|
1299
1320
|
_err.handler())
|
1300
1321
|
if _err.code != 0:
|
1301
1322
|
raise FactoryException(_err.what)
|
1302
1323
|
|
1324
|
+
def save_settings(self, output_path: Union[str, pathlib.Path],
|
1325
|
+
options: Optional[Union[dict, Value, DataObject]] = None):
|
1326
|
+
output_path = str(output_path)
|
1327
|
+
_err = Error()
|
1328
|
+
options_value = _get_arg_object(options)
|
1329
|
+
factorylib.lib.psrd_study_save_settings(self._hdr, _c_str(output_path),
|
1330
|
+
_bytes(output_path),
|
1331
|
+
options_value.handler(),
|
1332
|
+
_err.handler())
|
1333
|
+
if _err.code != 0:
|
1334
|
+
raise FactoryException(_err.what)
|
1335
|
+
|
1303
1336
|
@property
|
1304
1337
|
def context(self) -> "Context":
|
1305
1338
|
_check_initialized()
|
@@ -1377,6 +1410,16 @@ class Study(_BaseObject):
|
|
1377
1410
|
if _err.code != 0:
|
1378
1411
|
raise FactoryException(_err.what)
|
1379
1412
|
|
1413
|
+
def get_all_objects(self) -> List[DataObject]:
|
1414
|
+
object_list = ValueList(False)
|
1415
|
+
error = Error()
|
1416
|
+
ref = factorylib.lib.psrd_study_get_all_objects(self._hdr,
|
1417
|
+
error.handler())
|
1418
|
+
if error.code != 0 or ref is None:
|
1419
|
+
raise FactoryException(error.what)
|
1420
|
+
object_list._hdr = ref
|
1421
|
+
return object_list.to_list()
|
1422
|
+
|
1380
1423
|
def find(self, expression: str) -> List[DataObject]:
|
1381
1424
|
object_list = ValueList(False)
|
1382
1425
|
_err = Error()
|
@@ -1388,6 +1431,20 @@ class Study(_BaseObject):
|
|
1388
1431
|
object_list._hdr = ref
|
1389
1432
|
return object_list.to_list()
|
1390
1433
|
|
1434
|
+
def find_by_name(self, type_name: str, name: str) -> List[DataObject]:
|
1435
|
+
object_list = ValueList(False)
|
1436
|
+
_err = Error()
|
1437
|
+
if name.strip() == "":
|
1438
|
+
name = "*"
|
1439
|
+
expression = f"{type_name}.{name}"
|
1440
|
+
ref = factorylib.lib.psrd_study_find(self._hdr,
|
1441
|
+
_c_str(expression),
|
1442
|
+
_err.handler())
|
1443
|
+
if _err.code != 0 or ref is None:
|
1444
|
+
raise FactoryException(_err.what)
|
1445
|
+
object_list._hdr = ref
|
1446
|
+
return object_list.to_list()
|
1447
|
+
|
1391
1448
|
def find_by_code(self, type_name: str, code: Optional[int] = None) -> List[DataObject]:
|
1392
1449
|
if code is None:
|
1393
1450
|
warnings.warn(DeprecationWarning("Starting from Factory 4.0.9 "
|
@@ -2091,16 +2148,16 @@ class DataFrame(_BaseObject):
|
|
2091
2148
|
factorylib.lib.psrd_free_table(self._hdr)
|
2092
2149
|
|
2093
2150
|
@staticmethod
|
2094
|
-
def load_from_file(input_file: Union[str, pathlib.Path], options: Optional[DataObject] = None) -> "DataFrame":
|
2151
|
+
def load_from_file(input_file: Union[str, pathlib.Path], options: Optional[Union[dict, Value, DataObject]] = None) -> "DataFrame":
|
2095
2152
|
input_file = str(input_file)
|
2096
2153
|
_check_initialized()
|
2097
2154
|
_err = Error()
|
2098
2155
|
table = DataFrame()
|
2099
|
-
|
2156
|
+
options_value = _get_arg_object(options)
|
2100
2157
|
factorylib.lib.psrd_table_load(table.handler(),
|
2101
2158
|
_c_str(input_file),
|
2102
2159
|
_bytes(input_file),
|
2103
|
-
|
2160
|
+
options_value.handler(),
|
2104
2161
|
_err.handler())
|
2105
2162
|
if _err.code != 0:
|
2106
2163
|
raise FactoryException(_err.what)
|
@@ -2119,13 +2176,13 @@ class DataFrame(_BaseObject):
|
|
2119
2176
|
return df_builder.build_from_polars(dataframe_like)
|
2120
2177
|
raise ImportError("Pandas or polars is not available. Please install pandas to use this feature.")
|
2121
2178
|
|
2122
|
-
def save(self, output_file: Union[str, pathlib.Path], options: Optional[DataObject] = None):
|
2179
|
+
def save(self, output_file: Union[str, pathlib.Path], options: Optional[Union[dict, Value, DataObject]] = None):
|
2123
2180
|
output_file = str(output_file)
|
2124
2181
|
_err = Error()
|
2125
|
-
|
2182
|
+
options_value = _get_arg_object(options)
|
2126
2183
|
factorylib.lib.psrd_table_save(self._hdr, _c_str(output_file),
|
2127
2184
|
_bytes(output_file),
|
2128
|
-
|
2185
|
+
options_value.handler(),
|
2129
2186
|
_err.handler())
|
2130
2187
|
if _err.code != 0:
|
2131
2188
|
raise FactoryException(_err.what)
|
@@ -2235,7 +2292,15 @@ def create_study(*args, **kwargs) -> Study:
|
|
2235
2292
|
def load_study(study_path: Union[str, pathlib.Path],
|
2236
2293
|
profile_or_context: Union[str, Context, None] = None,
|
2237
2294
|
options: Optional[DataObject] = None) -> Study:
|
2238
|
-
|
2295
|
+
settings_only = False
|
2296
|
+
return Study.load(study_path, profile_or_context, settings_only, options)
|
2297
|
+
|
2298
|
+
|
2299
|
+
def load_study_settings(study_path: Union[str, pathlib.Path],
|
2300
|
+
profile_or_context: Union[str, Context, None] = None,
|
2301
|
+
options: Optional[DataObject] = None) -> Study:
|
2302
|
+
settings_only = True
|
2303
|
+
return Study.load(study_path, profile_or_context, settings_only, options)
|
2239
2304
|
|
2240
2305
|
|
2241
2306
|
def create(class_name: str,
|
psr/factory/factory.dll
CHANGED
Binary file
|