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")
def ca_cert_full_path(self) -> str: return get_media_full_path(self.ca_cert_file.file.name) if self.ca_cert_file else ""
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 ""
def encryption_key_full_path(self) -> str: return get_media_full_path(self.encryption_key_file.file.name) if self.encryption_key_file else ""
def signing_key_full_path(self) -> str: return get_media_full_path(self.signing_key_file.file.name) if self.signing_key_file else ""
def full_path(self) -> str: return get_media_full_path(self.file_path) if self.file_path else ""