Esempio n. 1
0
    def do(self, *args, **options):  # pylint: disable=too-many-locals
        ws = WsEdiConnection.objects.get(id=options["ws"])
        assert isinstance(ws, WsEdiConnection)
        if ws and not ws.enabled:
            logger.info("WS connection %s not enabled, exiting", ws)
            return

        start_date, end_date = parse_start_and_end_date(pytz.timezone("Europe/Helsinki"), **options)
        cmd = options["cmd"]
        file_reference = options["file_reference"] or ""
        file_type = options["file_type"] or ""
        status = options["status"] or ""
        response = wsedi_execute(
            ws,
            command=cmd,
            file_reference=file_reference,
            file_type=file_type,
            status=status,
            start_date=start_date,
            end_date=end_date,
            verbose=True,
        )
        print(response)
        root_el = ElementTree.fromstring(response)
        content_el = root_el.find("{http://bxd.fi/xmldata/}Content")
        if content_el is not None:
            content_bytes = base64.b64decode(content_el.text)
            print(content_bytes.decode())
            if file_reference:
                full_path = get_media_full_path("downloads/" + file_reference + "." + file_type)
                with open(full_path, "wb") as fp:
                    fp.write(content_bytes)
                    print(full_path, "written")
Esempio n. 2
0
 def ca_cert_full_path(self) -> str:
     return get_media_full_path(self.ca_cert_file.file.name) if self.ca_cert_file else ""
Esempio n. 3
0
 def bank_root_cert_full_path(self) -> str:
     return get_media_full_path(self.bank_root_cert_file.file.name) if self.bank_root_cert_file else ""
Esempio n. 4
0
 def encryption_key_full_path(self) -> str:
     return get_media_full_path(self.encryption_key_file.file.name) if self.encryption_key_file else ""
Esempio n. 5
0
 def signing_key_full_path(self) -> str:
     return get_media_full_path(self.signing_key_file.file.name) if self.signing_key_file else ""
Esempio n. 6
0
 def full_path(self) -> str:
     return get_media_full_path(self.file_path) if self.file_path else ""