当前位置: 首页>>代码示例>>Python>>正文


Python Utils.make_msgid方法代码示例

本文整理汇总了Python中email.Utils.make_msgid方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.make_msgid方法的具体用法?Python Utils.make_msgid怎么用?Python Utils.make_msgid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在email.Utils的用法示例。


在下文中一共展示了Utils.make_msgid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from email import Utils [as 别名]
# 或者: from email.Utils import make_msgid [as 别名]
def __init__(self, environment, refname, short_refname, old, new, rev):
        Change.__init__(self, environment)
        self.change_type = {
            (False, True): "create",
            (True, True): "update",
            (True, False): "delete",
        }[bool(old), bool(new)]
        self.refname = refname
        self.short_refname = short_refname
        self.old = old
        self.new = new
        self.rev = rev
        self.msgid = make_msgid()
        self.diffopts = environment.diffopts
        self.graphopts = environment.graphopts
        self.logopts = environment.logopts
        self.commitlogopts = environment.commitlogopts
        self.showgraph = environment.refchange_showgraph
        self.showlog = environment.refchange_showlog

        self.header_template = REFCHANGE_HEADER_TEMPLATE
        self.intro_template = REFCHANGE_INTRO_TEMPLATE
        self.footer_template = FOOTER_TEMPLATE 
开发者ID:Pagure,项目名称:pagure,代码行数:25,代码来源:git_multimail_upstream.py

示例2: test_make_msgid_collisions

# 需要导入模块: from email import Utils [as 别名]
# 或者: from email.Utils import make_msgid [as 别名]
def test_make_msgid_collisions(self):
        # Test make_msgid uniqueness, even with multiple threads
        class MsgidsThread(Thread):
            def run(self):
                # generate msgids for 3 seconds
                self.msgids = []
                append = self.msgids.append
                make_msgid = Utils.make_msgid
                clock = time.time
                tfin = clock() + 3.0
                while clock() < tfin:
                    append(make_msgid())

        threads = [MsgidsThread() for i in range(5)]
        with start_threads(threads):
            pass
        all_ids = sum([t.msgids for t in threads], [])
        self.assertEqual(len(set(all_ids)), len(all_ids)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:20,代码来源:test_email.py

示例3: test_make_msgid_collisions

# 需要导入模块: from email import Utils [as 别名]
# 或者: from email.Utils import make_msgid [as 别名]
def test_make_msgid_collisions(self):
        # Test make_msgid uniqueness, even with multiple threads
        class MsgidsThread(Thread):
            def run(self):
                # generate msgids for 3 seconds
                self.msgids = []
                append = self.msgids.append
                make_msgid = Utils.make_msgid
                clock = time.clock
                tfin = clock() + 3.0
                while clock() < tfin:
                    append(make_msgid())

        threads = [MsgidsThread() for i in range(5)]
        with start_threads(threads):
            pass
        all_ids = sum([t.msgids for t in threads], [])
        self.assertEqual(len(set(all_ids)), len(all_ids)) 
开发者ID:francelabs,项目名称:datafari,代码行数:20,代码来源:test_email.py

示例4: mail_headers

# 需要导入模块: from email import Utils [as 别名]
# 或者: from email.Utils import make_msgid [as 别名]
def mail_headers(self, group, params):
    from email import Utils
    subject = self.make_subject(group, params)
    try:
      subject.encode('ascii')
    except UnicodeError:
      from email.Header import Header
      subject = Header(subject, 'utf-8').encode()
    hdrs = 'From: %s\n'    \
           'To: %s\n'      \
           'Subject: %s\n' \
           'Date: %s\n' \
           'Message-ID: %s\n' \
           'MIME-Version: 1.0\n' \
           'Content-Type: text/plain; charset=UTF-8\n' \
           'Content-Transfer-Encoding: 8bit\n' \
           'X-Svn-Commit-Project: %s\n' \
           'X-Svn-Commit-Author: %s\n' \
           'X-Svn-Commit-Revision: %d\n' \
           'X-Svn-Commit-Repository: %s\n' \
           % (self.from_addr, ', '.join(self.to_addrs), subject, 
              Utils.formatdate(), Utils.make_msgid(), group,
              self.repos.author or 'no_author', self.repos.rev,
              os.path.basename(self.repos.repos_dir))
    if self.reply_to:
      hdrs = '%sReply-To: %s\n' % (hdrs, self.reply_to)
    return hdrs + '\n' 
开发者ID:znick,项目名称:anytask,代码行数:29,代码来源:mailer.py

示例5: send_mail

# 需要导入模块: from email import Utils [as 别名]
# 或者: from email.Utils import make_msgid [as 别名]
def send_mail(sender, receiver, subject, content, ctype="html", pics=()):
    """subject and body are unicode objects"""
    if not sender:
        sender = current_app.config.get("DEFAULT_MAIL_SENDER")
    smtp_server = current_app.config.get("MAIL_SERVER")
    if ctype == "html":
        msg = MIMEText(content, 'html', 'utf-8')
    else:
        msg = MIMEText(content, 'plain', 'utf-8')

    if len(pics) != 0:
        msg_root = MIMEMultipart('related')
        msg_text = MIMEText(content, 'html', 'utf-8')
        msg_root.attach(msg_text)
        i = 1
        for pic in pics:
            fp = open(pic, "rb")
            image = MIMEImage(fp.read())
            fp.close()
            image.add_header('Content-ID', '<img%02d>' % i)
            msg_root.attach(image)
            i += 1
        msg = msg_root

    msg['Subject'] = Header(subject, 'utf-8')
    msg['From'] = sender
    msg['To'] = ';'.join(receiver)
    msg['Message-ID'] = Utils.make_msgid()
    msg['date'] = time.strftime('%a, %d %b %Y %H:%M:%S %z')

    smtp = smtplib.SMTP()
    smtp.connect(smtp_server, 25)
    username, password = current_app.config.get("MAIL_USERNAME"), current_app.config.get("MAIL_PASSWORD")
    if username and password:
        smtp.login(username, password)
    smtp.sendmail(sender, receiver, msg.as_string())
    smtp.quit() 
开发者ID:pycook,项目名称:cmdb,代码行数:39,代码来源:mail.py


注:本文中的email.Utils.make_msgid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。