Skip to content

Commit

Permalink
Acavar p0 gas
Browse files Browse the repository at this point in the history
  • Loading branch information
eberloso committed Sep 26, 2023
1 parent 264184c commit 5e4b7af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 91 deletions.
20 changes: 9 additions & 11 deletions gestionatr/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import six
import sys
import click
import re
from suds.cache import NoCache
from suds.client import Client
from suds.transport.https import HttpAuthenticated
Expand Down Expand Up @@ -127,17 +128,18 @@ def request_atr_29(url, user, password, xml_str=None, params=None):
xml_str = xml_str.strip()
xml_str = xml_str.replace("'utf-8'", "'UTF-8'")
xml_str = xml_str.replace("<?xml version='1.0' encoding='UTF-8'?>", "")
xml_str = xml_str.replace("""<sctdapplication xmlns="http://localhost/sctd/A529">""", "")
xml_str = xml_str.replace("""</sctdapplication>""", "")
xml_str = xml_str.replace("<", "<a529:")
xml_str = xml_str.replace("<a529:/", "</a529:")

# Fem sempre 2 intents: amb el que esta definit per aquella distri i si va malament amb una plantilla base que
# sol funcionar en la majoria. Aixi si una distri no la tenim documentada es fa el intent amb les 2 plantilles
# principals que tenim. La "altres" i la "reintent"

distri_envelop = ENVELOP_GAS_BY_DISTR.get(codi_receptor, ENVELOP_GAS_BY_DISTR.get("altres"))
retry_envelop = ENVELOP_GAS_BY_DISTR.get("reintent")
retry_envelop2 = ENVELOP_GAS_BY_DISTR.get("reintent2")
retry_envelop3 = ENVELOP_GAS_BY_DISTR.get("reintent3")
error = None
for envelop in [distri_envelop, retry_envelop, retry_envelop2, retry_envelop3]:
for envelop in [distri_envelop]:
xml_str_to_use = xml_str
soap_content = envelop['template'].format(xml_str=xml_str_to_use)

Expand All @@ -157,16 +159,12 @@ def find_child(element, child_name):
break
return res

res = re.sub(r'\<[^: \n/]+:', '<', res)
res = re.sub(r'\</[^: \n/]+:', '</', res)
res = res.replace("consultaCupsResponse", "a629")
aux = etree.fromstring(res)
aux_res = find_child(aux, "a629")

if aux_res is not None:
error_mssg = {
'request': res,
'response': etree.tostring(aux_res)
}
raise A529FaultError(error_mssg)

res = etree.tostring(aux_res)
return res
except A529FaultError as A529efe:
Expand Down
85 changes: 5 additions & 80 deletions gestionatr/output/messages/sw_a5_29.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,103 +46,28 @@ def __init__(self):
super(ValidacionClienteA529, self).__init__('validacioncliente', 'validacioncliente')


GAS_ENVELOPE_TEMPLATE_AMB_NAMESPACE_AL_PAS = """
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:eleg="http://localhost/sctd/wsrps"
>
<soap:Header />
<soap:Body>
<eleg:consultaCups>
<eleg:consultaCups>
{xml_str}
</eleg:consultaCups>
</eleg:consultaCups>
</soap:Body>
</soap:Envelope>
"""

GAS_ENVELOPE_TEMPLATE_SENSE_NAMESPACE_AL_PAS01 = """
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:eleg="http://localhost/sctd/wsrps"
>
<soap:Header />
<soap:Body>
<eleg:consultaCups>
<consultaCups>
{xml_str}
</consultaCups>
</eleg:consultaCups>
</soap:Body>
</soap:Envelope>
"""

GAS_ENVELOPE_TEMPLATE_CHATGPT = """
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:wsrps="http://localhost/sctd/wsrps"
xmlns:wsr="http://localhost/sctd/wsrps"
xmlns:a529="http://localhost/sctd/A529">
<soapenv:Header/>
<soapenv:Body>
<wsrps:consultaCups>
<wsrps:consultaCups>
{xml_str}
</wsrps:consultaCups>
</wsrps:consultaCups>
</soapenv:Body>
</soapenv:Envelope>
"""

GAS_ENVELOPE_TEMPLATE_CHATGPT_v2 = """
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:wsrps="http://localhost/sctd/wsrps">
<soapenv:Header/>
<soapenv:Body>
<wsrps:consultaCups>
<wsrps:consultaCups>
<wsr:consultaCups>
<consultaCups>
{xml_str}
</wsrps:consultaCups>
</wsrps:consultaCups>
</consultaCups>
</wsr:consultaCups>
</soapenv:Body>
</soapenv:Envelope>
"""


ENVELOP_GAS_BY_DISTR = {
'altres': {
'template': GAS_ENVELOPE_TEMPLATE_SENSE_NAMESPACE_AL_PAS01,
'extra_headers': {
"soapAction": ""
},
},
'reintent': {
'template': GAS_ENVELOPE_TEMPLATE_AMB_NAMESPACE_AL_PAS,
'extra_headers': {
"soapAction": ""
},
},
'reintent2': {
'template': GAS_ENVELOPE_TEMPLATE_CHATGPT,
'extra_headers': {
"soapAction": ""
},
},
'reintent3': {
'template': GAS_ENVELOPE_TEMPLATE_CHATGPT,
'extra_headers': {
},
},
'reintent4': {
'template': GAS_ENVELOPE_TEMPLATE_CHATGPT_v2,
'extra_headers': {
"soapAction": ""
},
},
'reintent5': {
'template': GAS_ENVELOPE_TEMPLATE_CHATGPT_v2,
'extra_headers': {
},
},
}

0 comments on commit 5e4b7af

Please sign in to comment.