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


Python TicketNotifyEmail.notify方法代码示例

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


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

示例1: add_tickets

# 需要导入模块: from trac.ticket.notification import TicketNotifyEmail [as 别名]
# 或者: from trac.ticket.notification.TicketNotifyEmail import notify [as 别名]
    def add_tickets(self, project, customerrequest, tickets, reporter, notify=False):
        from trac.ticket.notification import TicketNotifyEmail
        from trac.util.text import exception_to_unicode
        from penelope.core.models.dashboard import User

        settings = get_current_registry().settings
        tracenvs = settings.get('penelope.trac.envs')
        request = get_current_request()

        for trac in project.tracs:
            for t in tickets:
                owner = DBSession.query(User).get(t['owner'])
                ticket = {'summary': t['summary'],
                        'description': t['description'],
                        'customerrequest': customerrequest.id,
                        'reporter': reporter.email,
                        'type': 'task',
                        'priority': 'major',
                        'milestone': 'Backlog',
                        'owner': owner.email,
                        'status': 'new'}
                tracenv = Environment('%s/%s' % (tracenvs, trac.trac_name))
                tracenv.abs_href.base = trac.api_uri
                t = Ticket(tracenv)
                t.populate(ticket)
                t.insert()
                if notify:
                    try:
                        tn = TicketNotifyEmail(tracenv)
                        tn.notify(t, newticket=True)
                    except Exception, e:
                        request.add_message('Failure sending notification on creation '
                        'of a ticket #%s: %s' % (t.id, exception_to_unicode(e)), 'error')
开发者ID:getpenelope,项目名称:penelope.core,代码行数:35,代码来源:tickets.py

示例2: test_recipients

# 需要导入模块: from trac.ticket.notification import TicketNotifyEmail [as 别名]
# 或者: from trac.ticket.notification.TicketNotifyEmail import notify [as 别名]
 def test_recipients(self):
     """To/Cc recipients"""
     ticket = Ticket(self.env)
     ticket['reporter'] = '"Joe User" <[email protected]>'
     ticket['owner']    = '[email protected]'
     ticket['cc']       = '[email protected], [email protected], ' \
                          '[email protected]'
     ticket['summary'] = 'Foo'
     ticket.insert()
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=True)
     recipients = notifysuite.smtpd.get_recipients()
     # checks there is no duplicate in the recipient list
     rcpts = []
     for r in recipients:
         self.failIf(r in rcpts)
         rcpts.append(r)
     # checks that all cc recipients have been notified
     cc_list = self.env.config.get('notification', 'smtp_always_cc')
     cc_list = "%s, %s" % (cc_list, ticket['cc'])
     for r in cc_list.replace(',', ' ').split():
         self.failIf(r not in recipients)
     # checks that owner has been notified
     self.failIf(smtp_address(ticket['owner']) not in recipients)
     # checks that reporter has been notified
     self.failIf(smtp_address(ticket['reporter']) not in recipients)
开发者ID:cyphactor,项目名称:lifecyclemanager,代码行数:28,代码来源:notification.py

示例3: test_email_map

# 需要导入模块: from trac.ticket.notification import TicketNotifyEmail [as 别名]
# 或者: from trac.ticket.notification.TicketNotifyEmail import notify [as 别名]
 def test_email_map(self):
     """Login-to-email mapping"""
     self.env.config.set("notification", "always_notify_owner", "true")
     self.env.config.set("notification", "always_notify_reporter", "true")
     self.env.config.set("notification", "smtp_always_cc", "[email protected]")
     self.env.known_users = [
         ("joeuser", "Joe User", "[email protected]"),
         ("[email protected]", "Jim User", "[email protected]"),
     ]
     ticket = Ticket(self.env)
     ticket["reporter"] = "joeuser"
     ticket["owner"] = "[email protected]"
     ticket["summary"] = "This is a summary"
     ticket.insert()
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=True)
     message = notifysuite.smtpd.get_message()
     (headers, body) = parse_smtp_message(message)
     # Msg should always have a 'To' field
     self.failIf("To" not in headers)
     tolist = [addr.strip() for addr in headers["To"].split(",")]
     # 'To' list should have been resolved to the real email address
     self.failIf("[email protected]" not in tolist)
     self.failIf("[email protected]" not in tolist)
     self.failIf("joeuser" in tolist)
     self.failIf("[email protected]" in tolist)
开发者ID:moreati,项目名称:trac-gitsvn,代码行数:28,代码来源:notification.py

示例4: _test_short_login

# 需要导入模块: from trac.ticket.notification import TicketNotifyEmail [as 别名]
# 或者: from trac.ticket.notification.TicketNotifyEmail import notify [as 别名]
 def _test_short_login(enabled):
     ticket = Ticket(self.env)
     ticket["reporter"] = "joeuser"
     ticket["summary"] = "This is a summary"
     ticket.insert()
     # Be sure that at least one email address is valid, so that we
     # send a notification even if other addresses are not valid
     self.env.config.set("notification", "smtp_always_cc", "[email protected]")
     if enabled:
         self.env.config.set("notification", "use_short_addr", "true")
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=True)
     message = notifysuite.smtpd.get_message()
     (headers, body) = parse_smtp_message(message)
     # Msg should not have a 'To' header
     if not enabled:
         self.failIf("To" in headers)
     else:
         tolist = [addr.strip() for addr in headers["To"].split(",")]
     # Msg should have a 'Cc' field
     self.failIf("Cc" not in headers)
     cclist = [addr.strip() for addr in headers["Cc"].split(",")]
     if enabled:
         # Msg should be delivered to the reporter
         self.failIf(ticket["reporter"] not in tolist)
     else:
         # Msg should not be delivered to joeuser
         self.failIf(ticket["reporter"] in cclist)
     # Msg should still be delivered to the always_cc list
     self.failIf(self.env.config.get("notification", "smtp_always_cc") not in cclist)
开发者ID:moreati,项目名称:trac-gitsvn,代码行数:32,代码来源:notification.py

示例5: _test_default_domain

# 需要导入模块: from trac.ticket.notification import TicketNotifyEmail [as 别名]
# 或者: from trac.ticket.notification.TicketNotifyEmail import notify [as 别名]
 def _test_default_domain(enabled):
     self.env.config.set("notification", "always_notify_owner", "false")
     self.env.config.set("notification", "always_notify_reporter", "false")
     self.env.config.set("notification", "smtp_always_cc", "")
     ticket = Ticket(self.env)
     ticket["cc"] = "joenodom, [email protected]"
     ticket["summary"] = "This is a summary"
     ticket.insert()
     # Be sure that at least one email address is valid, so that we
     # send a notification even if other addresses are not valid
     self.env.config.set("notification", "smtp_always_cc", "[email protected]")
     if enabled:
         self.env.config.set("notification", "smtp_default_domain", "example.org")
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=True)
     message = notifysuite.smtpd.get_message()
     (headers, body) = parse_smtp_message(message)
     # Msg should always have a 'Cc' field
     self.failIf("Cc" not in headers)
     cclist = [addr.strip() for addr in headers["Cc"].split(",")]
     self.failIf("[email protected]" not in cclist)
     self.failIf("[email protected]" not in cclist)
     if not enabled:
         self.failIf(len(cclist) != 2)
         self.failIf("joenodom" in cclist)
     else:
         self.failIf(len(cclist) != 3)
         self.failIf("[email protected]" not in cclist)
开发者ID:moreati,项目名称:trac-gitsvn,代码行数:30,代码来源:notification.py

示例6: test_date

# 需要导入模块: from trac.ticket.notification import TicketNotifyEmail [as 别名]
# 或者: from trac.ticket.notification.TicketNotifyEmail import notify [as 别名]
 def test_date(self):
     """Date format compliance (RFC822) 
        we do not support 'military' format"""
     date_str = (
         r"^((?P<day>\w{3}),\s*)*(?P<dm>\d{2})\s+"
         r"(?P<month>\w{3})\s+(?P<year>\d{4})\s+"
         r"(?P<hour>\d{2}):(?P<min>[0-5][0-9])"
         r"(:(?P<sec>[0-5][0-9]))*\s"
         r"((?P<tz>\w{2,3})|(?P<offset>[+\-]\d{4}))$"
     )
     date_re = re.compile(date_str)
     # python time module does not detect incorrect time values
     days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
     months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
     tz = ["UT", "GMT", "EST", "EDT", "CST", "CDT", "MST", "MDT", "PST", "PDT"]
     ticket = Ticket(self.env)
     ticket["reporter"] = '"Joe User" <[email protected]>'
     ticket["summary"] = "This is a summary"
     ticket.insert()
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=True)
     message = notifysuite.smtpd.get_message()
     (headers, body) = parse_smtp_message(message)
     self.failIf("Date" not in headers)
     mo = date_re.match(headers["Date"])
     self.failIf(not mo)
     if mo.group("day"):
         self.failIf(mo.group("day") not in days)
     self.failIf(int(mo.group("dm")) not in range(1, 32))
     self.failIf(mo.group("month") not in months)
     self.failIf(int(mo.group("hour")) not in range(0, 24))
     if mo.group("tz"):
         self.failIf(mo.group("tz") not in tz)
开发者ID:moreati,项目名称:trac-gitsvn,代码行数:35,代码来源:notification.py

示例7: test_ignore_domains

# 需要导入模块: from trac.ticket.notification import TicketNotifyEmail [as 别名]
# 或者: from trac.ticket.notification.TicketNotifyEmail import notify [as 别名]
 def test_ignore_domains(self):
     """Non-SMTP domain exclusion"""
     self.env.config.set('notification', 'ignore_domains',
                         'example.com, example.org')
     self.env.known_users = \
         [('[email protected]', 'No Email', ''), 
          ('[email protected]', 'With Email', '[email protected]')]
     ticket = Ticket(self.env)
     ticket['reporter'] = '[email protected]'
     ticket['owner'] = '[email protected]'
     ticket['summary'] = 'This is a summary'
     ticket.insert()
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=True)
     message = notifysuite.smtpd.get_message()
     (headers, body) = parse_smtp_message(message)
     # Msg should always have a 'To' field
     self.failIf('To' not in headers)
     tolist = [addr.strip() for addr in headers['To'].split(',')]
     # 'To' list should not contain addresses with non-SMTP domains
     self.failIf('[email protected]' in tolist)
     self.failIf('[email protected]' in tolist)
     # 'To' list should have been resolved to the actual email address
     self.failIf('[email protected]' not in tolist)
     self.failIf(len(tolist) != 1)
开发者ID:gdgkyoto,项目名称:kyoto-gtug,代码行数:27,代码来源:notification.py

示例8: handle_commit

# 需要导入模块: from trac.ticket.notification import TicketNotifyEmail [as 别名]
# 或者: from trac.ticket.notification.TicketNotifyEmail import notify [as 别名]
def handle_commit(commit, env):
    from trac.ticket.notification import TicketNotifyEmail
    from trac.ticket import Ticket
    from trac.util.text import to_unicode
    from trac.util.datefmt import utc

    msg = to_unicode(call_git('rev-list', ['-n', '1', commit, '--pretty=medium']).rstrip())
    eml = to_unicode(call_git('rev-list', ['-n', '1', commit, '--pretty=format:%ae']).splitlines()[1])
    now = datetime.now(utc)

    tickets = {}
    for cmd, tkts in command_re.findall(msg.split('\n\n', 1)[1]):
        action = COMMANDS.get(cmd.lower())
        if action:
            for tkt_id in ticket_re.findall(tkts):
                tickets.setdefault(tkt_id, []).append(action)

    for tkt_id, actions in tickets.iteritems():
        try:
            db = env.get_db_cnx()
            ticket = Ticket(env, int(tkt_id), db)

            if 'close' in actions:
                ticket['status'] = 'closed'
                ticket['resolution'] = 'fixed'

            # trac 1.0: `db` parameter is no longer needed and will be removed in 1.1.1
            # trac 1.0: `cnum` parameter is deprecated
            ticket.save_changes(eml, msg, now)
            db.commit()

            tn = TicketNotifyEmail(env)
            tn.notify(ticket, newticket=0, modtime=now)
        except Exception, e:
            print >>sys.stderr, 'Unexpected error while processing ticket ID %s: %s' % (tkt_id, e)
开发者ID:Kurt-P,项目名称:auto-trac,代码行数:37,代码来源:trac-post-receive-hook.4.py

示例9: test_ignore_domains

# 需要导入模块: from trac.ticket.notification import TicketNotifyEmail [as 别名]
# 或者: from trac.ticket.notification.TicketNotifyEmail import notify [as 别名]
 def test_ignore_domains(self):
     """Non-SMTP domain exclusion"""
     self.env.config.set("notification", "ignore_domains", "example.com, example.org")
     self.env.known_users = [
         ("[email protected]", "No Email", ""),
         ("[email protected]", "With Email", "[email protected]"),
     ]
     ticket = Ticket(self.env)
     ticket["reporter"] = "[email protected]"
     ticket["owner"] = "[email protected]ple.org"
     ticket["summary"] = "This is a summary"
     ticket.insert()
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=True)
     message = notifysuite.smtpd.get_message()
     (headers, body) = parse_smtp_message(message)
     # Msg should always have a 'To' field
     self.failIf("To" not in headers)
     tolist = [addr.strip() for addr in headers["To"].split(",")]
     # 'To' list should not contain addresses with non-SMTP domains
     self.failIf("[email protected]" in tolist)
     self.failIf("[email protected]" in tolist)
     # 'To' list should have been resolved to the actual email address
     self.failIf("[email protected]" not in tolist)
     self.failIf(len(tolist) != 1)
开发者ID:moreati,项目名称:trac-gitsvn,代码行数:27,代码来源:notification.py

示例10: _save_ticket_changes

# 需要导入模块: from trac.ticket.notification import TicketNotifyEmail [as 别名]
# 或者: from trac.ticket.notification.TicketNotifyEmail import notify [as 别名]
    def _save_ticket_changes(self, req, env, log, selectedTickets, tickets,
                             values, comment, modify_changetime, send_notifications):
        for id in selectedTickets:
            if id in tickets:
                t = Ticket(env, int(id))
                new_changetime = datetime.now(utc)
                
                log_msg = ""
                if not modify_changetime:
                    original_changetime = to_timestamp(t.time_changed)
                
                _values = values.copy()
                for field in [f for f in values.keys() \
                              if f in self._fields_as_list]:
                    _values[field] = self._merge_keywords(t.values[field], 
                                                          values[field],
                                                          log)
                
                t.populate(_values)
                t.save_changes(req.authname, comment, when=new_changetime)
  
                if send_notifications:
                    tn = TicketNotifyEmail(env)
                    tn.notify(t, newticket=0, modtime=new_changetime)

                if not modify_changetime:
                    self._reset_changetime(env, original_changetime, t)
                    log_msg = "(changetime not modified)"

                log.debug('BatchModifyPlugin: saved changes to #%s %s' % 
                          (id, log_msg))
开发者ID:lkraav,项目名称:trachacks,代码行数:33,代码来源:web_ui.py

示例11: test_date

# 需要导入模块: from trac.ticket.notification import TicketNotifyEmail [as 别名]
# 或者: from trac.ticket.notification.TicketNotifyEmail import notify [as 别名]
 def test_date(self):
     """Date format compliance (RFC822) 
        we do not support 'military' format""" 
     date_str = r"^((?P<day>\w{3}),\s*)*(?P<dm>\d{2})\s+" \
                r"(?P<month>\w{3})\s+(?P<year>200\d)\s+" \
                r"(?P<hour>\d{2}):(?P<min>[0-5][0-9])" \
                r"(:(?P<sec>[0-5][0-9]))*\s" \
                r"((?P<tz>\w{2,3})|(?P<offset>[+\-]\d{4}))$"
     date_re = re.compile(date_str)
     # python time module does not detect incorrect time values
     days = ['Mon','Tue','Wed','Thu','Fri','Sat','Sun']
     months = ['Jan','Feb','Mar','Apr','May','Jun', \
               'Jul','Aug','Sep','Oct','Nov','Dec']
     tz = ['UT','GMT','EST','EDT','CST','CDT','MST','MDT''PST','PDT']
     ticket = Ticket(self.env)
     ticket['reporter'] = '"Joe User" <[email protected]>'
     ticket['summary'] = 'This is a summary'
     ticket.insert()
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=True)
     message = notifysuite.smtpd.get_message()
     (headers, body) = parse_smtp_message(message)
     self.failIf('Date' not in headers)
     mo = date_re.match(headers['Date'])
     self.failIf(not mo)
     if mo.group('day'):
         self.failIf(mo.group('day') not in days)
     self.failIf(int(mo.group('dm')) not in range(1,32))
     self.failIf(mo.group('month') not in months)
     self.failIf(int(mo.group('hour')) not in range(0,24))
     if mo.group('tz'):
         self.failIf(mo.group('tz') not in tz)
开发者ID:cyphactor,项目名称:lifecyclemanager,代码行数:34,代码来源:notification.py

示例12: save_ticket

# 需要导入模块: from trac.ticket.notification import TicketNotifyEmail [as 别名]
# 或者: from trac.ticket.notification.TicketNotifyEmail import notify [as 别名]
 def save_ticket(self, tckt, db, msg):
     # determine sequence number... 
     cnum = 0
     tm = TicketModule(self.env)
     for change in tm.grouped_changelog_entries(tckt, db):
         if change['permanent']:
             cnum += 1
     tckt.save_changes(self.authname, msg, self.now, db, cnum+1)
     ## Often the time overlaps and causes a db error,
     ## especially when the trac integration post-commit hook is used.
     ## NOTE TO SELF. I DON'T THINK THIS IS NECESSARY RIGHT NOW...
     #count = 0
     #while count < 10:
     #    try:
     #        tckt.save_changes(self.authname, msg, self.now, db, cnum+1)
     #        count = 42
     #    except Exception, e:
     #        self.now += 1
     #        count += 1
     db.commit()
     
     tn = TicketNotifyEmail(self.env)
     tn.notify(tckt, newticket=0, modtime=self.now)
     # We fudge time as it has to be unique
     self.now += 1
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:27,代码来源:manager.py

示例13: _test_default_domain

# 需要导入模块: from trac.ticket.notification import TicketNotifyEmail [as 别名]
# 或者: from trac.ticket.notification.TicketNotifyEmail import notify [as 别名]
 def _test_default_domain(enabled):
     self.env.config.set('notification', 'always_notify_owner',
                         'false')
     self.env.config.set('notification', 'always_notify_reporter',
                         'false')
     self.env.config.set('notification', 'smtp_always_cc', '')
     ticket = Ticket(self.env)
     ticket['cc'] = 'joenodom, [email protected]'
     ticket['summary'] = 'This is a summary'
     ticket.insert()
     # Be sure that at least one email address is valid, so that we 
     # send a notification even if other addresses are not valid
     self.env.config.set('notification', 'smtp_always_cc',
                         '[email protected]')
     if enabled:
         self.env.config.set('notification', 'smtp_default_domain',
                             'example.org')
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=True)
     message = notifysuite.smtpd.get_message()
     (headers, body) = parse_smtp_message(message)
     # Msg should always have a 'Cc' field
     self.failIf('Cc' not in headers)
     cclist = [addr.strip() for addr in headers['Cc'].split(',')]
     self.failIf('[email protected]' not in cclist)
     self.failIf('[email protected]' not in cclist)
     if not enabled:
         self.failIf(len(cclist) != 2)
         self.failIf('joenodom' in cclist)
     else:
         self.failIf(len(cclist) != 3)
         self.failIf('[email protected]' not in cclist)
开发者ID:cyphactor,项目名称:lifecyclemanager,代码行数:34,代码来源:notification.py

示例14: apply_action_side_effects

# 需要导入模块: from trac.ticket.notification import TicketNotifyEmail [as 别名]
# 或者: from trac.ticket.notification.TicketNotifyEmail import notify [as 别名]
    def apply_action_side_effects(self, req, ticket, action):
        """Add a cross-reference comment to the other ticket"""
        # TODO: This needs a lot more error checking.
        id = 'action_%s_xref' % action
        ticketnum = req.args.get(id).strip('#')
        actions = self.get_configurable_workflow().actions
        author = req.authname

        # Add a comment to the "remote" ticket to indicate this ticket is
        # related to it.
        format_string = actions[action].get('xref',
                                        'Ticket %s is related to this ticket')
        comment = format_string % ('#%s' % ticket.id)
        # FIXME: we need a cnum to avoid messing up 
        xticket = model.Ticket(self.env, ticketnum)
        # FIXME: We _assume_ we have sufficient permissions to comment on the
        # other ticket.
        now = datetime.now(utc)
        xticket.save_changes(author, comment, now)

        #Send notification on the other ticket
        try:
            tn = TicketNotifyEmail(self.env)
            tn.notify(xticket, newticket=False, modtime=now)
        except Exception, e:
            self.log.exception("Failure sending notification on change to "
                               "ticket #%s: %s" % (ticketnum, e))
开发者ID:lkraav,项目名称:trachacks,代码行数:29,代码来源:controller.py

示例15: create

# 需要导入模块: from trac.ticket.notification import TicketNotifyEmail [as 别名]
# 或者: from trac.ticket.notification.TicketNotifyEmail import notify [as 别名]
    def create(self, req, summary, description, attributes={}, notify=False):
        """ Create a new ticket, returning the ticket ID.

        PS: Borrowed from XmlRpcPlugin.
        """
        if 'product' in attributes:
            env = self.env.parent or self.env
            if attributes['product']:
                env = ProductEnvironment(env, attributes['product'])
        else:
            env = self.env

        t = Ticket(env)
        t['summary'] = summary
        t['description'] = description
        t['reporter'] = req.authname
        for k, v in attributes.iteritems():
            t[k] = v
        t['status'] = 'new'
        t['resolution'] = ''
        t.insert()

        if notify:
            try:
                tn = TicketNotifyEmail(env)
                tn.notify(t, newticket=True)
            except Exception, e:
                self.log.exception("Failure sending notification on creation "
                                   "of ticket #%s: %s" % (t.id, e))
开发者ID:mohsadki,项目名称:dargest,代码行数:31,代码来源:theme.py


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