import gpg from serenitas.utils.exchange import ExchangeMessage em = ExchangeMessage() for msg in em.get_msgs(path=["SeleneOps", "Passport"]): for attach in msg.attachments: if attach.name == "Attachment1.pgp": try: with attach.fp as fp: plaintext, result, verify_result = gpg.Context().decrypt( fp.read(), passphrase="Serenitas1" ) except gpg.errors.GPGMEError as e: print(e)