コード例 #1
0
def preview_queued_msg(msgid, direction, attachid=None, imgid=None):
    "Preview a queued message"
    try:
        logger = preview_queued_msg.get_logger()
        header = search_queue(msgid, int(direction))
        convertor = Exim2Mbox(header)
        mbox = convertor()
        msgfile = StringIO(mbox)
        previewer = PreviewMessage(msgfile)
        if attachid:
            logger.info(
                _("Download attachment: %(attachid)s of "
                  "message: %(id)s"), dict(id=msgid, attachid=attachid))
            return previewer.attachment(attachid)
        if imgid:
            logger.info(_("Image access: %(img)s"), dict(img=imgid))
            return previewer.img(imgid)
        logger.info(_("Preview of message: %(id)s"), dict(id=msgid))
        return previewer.preview()
    except TypeError:
        return {}
    except (AssertionError, IOError), error:
        logger.info(_("Accessing message: %(id)s, Failed: %(error)s"),
                    dict(id=msgid, error=error))
        return None
コード例 #2
0
ファイル: status.py プロジェクト: aureg/baruwa2
def preview_queued_msg(msgid, direction, attachid=None, imgid=None):
    "Preview a queued message"
    try:
        logger = preview_queued_msg.get_logger()
        header = search_queue(msgid, int(direction))
        convertor = Exim2Mbox(header)
        mbox = convertor()
        msgfile = StringIO(mbox)
        previewer = PreviewMessage(msgfile)
        if attachid:
            logger.info(_("Download attachment: %(attachid)s of "
                        "message: %(id)s"),
                        dict(id=msgid, attachid=attachid))
            return previewer.attachment(attachid)
        if imgid:
            logger.info(_("Image access: %(img)s"), dict(img=imgid))
            return previewer.img(imgid)
        logger.info(_("Preview of message: %(id)s"), dict(id=msgid))
        return previewer.preview()
    except TypeError:
        return {}
    except (AssertionError, IOError), error:
        logger.info(_("Accessing message: %(id)s, Failed: %(error)s"),
        dict(id=msgid, error=error))
        return None
コード例 #3
0
ファイル: messages.py プロジェクト: extremeshok/baruwa2
def preview_msg(messageid, date, msgfiles, attachid=None, imgid=None, allowimgs=None):
    "Preview message"
    logger = preview_msg.get_logger()
    try:
        msgfile, _ = search_quarantine(date, messageid, msgfiles)
        previewer = PreviewMessage(msgfile)

        if attachid:
            logger.info(
                "Download attachment: %(attachid)s of " "message: %(id)s", dict(id=messageid, attachid=attachid)
            )
            return previewer.attachment(attachid)
        if imgid:
            logger.info("Image access: %(img)s", dict(img=imgid))
            return previewer.img(imgid)
        logger.info("Preview of message: %(id)s", dict(id=messageid))
        return previewer.preview()
    except IOError, error:
        logger.info("Accessing message: %(id)s, Failed: %(error)s", dict(id=messageid, error=error))
        return {}
コード例 #4
0
ファイル: messages.py プロジェクト: haugvald/baruwa2
def preview_msg(messageid, date, attachid=None, imgid=None, allowimgs=None):
    "Preview message"
    logger = preview_msg.get_logger()
    try:
        msgfile, isdir = search_quarantine(date, messageid)
        previewer = PreviewMessage(msgfile)

        if attachid:
            logger.info(
                "Download attachment: %(attachid)s of "
                "message: %(id)s", dict(id=messageid, attachid=attachid))
            return previewer.attachment(attachid)
        if imgid:
            logger.info("Image access: %(img)s", dict(img=imgid))
            return previewer.img(imgid)
        logger.info("Preview of message: %(id)s", dict(id=messageid))
        return previewer.preview()
    except TypeError, error:
        logger.info("Accessing message: %(id)s, Failed: %(error)s",
                    dict(id=messageid, error=error))
        return {}