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


Python TicketModule.grouped_changelog_entries方法代码示例

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


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

示例1: attachment_added

# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import grouped_changelog_entries [as 别名]
    def attachment_added(self, attachment):
        # Check whether we're dealing with a ticket resource
        resource = attachment.resource
        while resource:
            if resource.realm == 'ticket':
                break
            resource = resource.parent

        if (resource and resource.realm == 'ticket' and resource.id is not None):
            with self.env.db_transaction as db:
                ticket = Ticket(attachment.env, resource.id, db)
                if (attachment.author == ticket['reporter'] and ticket['status'] == 'pending'):
                    self.env.log.info('Removing Pending status for ticket %s due to attachment' % (ticket.id))

                    comment = 'Attachment (%s) added by ticket reporter.' % (attachment.filename)
                    ticket['status'] = self.config.get('ticket', 'pending_removal_status')

                    # determine sequence number...
                    cnum = 0
                    tm = TicketModule(self.env)
                    for change in tm.grouped_changelog_entries(ticket, db):
                        c_cnum = change.get('cnum', None)
                        if c_cnum and int(c_cnum) > cnum:
                            cnum = int(c_cnum)

                    #We can't just use attachment.date as it screws up event sequencing
                    now = datetime.now(utc)

                    ticket.save_changes(attachment.author, comment, now, db, str(cnum + 1))

                    #trigger notification since we've changed the ticket
                    tn = TicketNotifyEmail(self.env)
                    tn.notify(ticket, newticket=False, modtime=now)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:35,代码来源:remove_pending.py

示例2: post_to_ticket

# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import grouped_changelog_entries [as 别名]
def post_to_ticket(msg, author, tkt_id, env):
    """Post the message to the ticket and send a notify email."""
    from trac.ticket.notification import TicketNotifyEmail
    from trac.ticket import Ticket
    from trac.ticket.web_ui import TicketModule
    from trac.util.datefmt import utc

    now = datetime.now(utc)

    try:
        db = env.get_db_cnx()
        # Get the related trac ticket object
        ticket = Ticket(env, tkt_id, db)

        # determine sequence number...
        cnum = 0
        tm = TicketModule(env)
        for change in tm.grouped_changelog_entries(ticket, db):
            if change['permanent']:
                cnum += 1

        ticket.save_changes(author, msg, now, db, cnum + 1)
        db.commit()

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

示例3: save_ticket

# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import grouped_changelog_entries [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

示例4: process

# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import grouped_changelog_entries [as 别名]
    def process(self, commit, status, branch):
        self.closestatus = status

        milestones = [m.name for m in Milestone.select(self.env) if m.name != "unknown"]
        if branch.startswith("fixes/"):
            branch = branch[6:]
            milestones = [m for m in milestones if m.startswith(branch)]
        self.milestone = sorted(milestones)[-1]

        msg = commit["message"]
        self.env.log.debug("Processing Commit: %s", msg)
        msg = "%s \n Branch:    %s \n Changeset: %s" % (msg, branch, commit["id"])
        #        author = commit['author']['name']
        author = "Github"
        timestamp = datetime.now(utc)

        cmd_groups = command_re.findall(msg)
        self.env.log.debug("Function Handlers: %s" % cmd_groups)

        tickets = {}
        for cmd, tkts in cmd_groups:
            funcname = self.__class__._supported_cmds.get(cmd.lower(), "")
            self.env.log.debug("Function Handler: %s" % funcname)
            if funcname:
                for tkt_id in ticket_re.findall(tkts):
                    if (branch == "master") or branch.startswith("fixes/"):
                        tickets.setdefault(tkt_id, []).append(getattr(self, funcname))
        #                    disable this stuff for now, it causes duplicates on merges
        #                    proper implementation of this will require tracking commit hashes
        #                    else:
        #                        tickets.setdefault(tkt_id, []).append(self._cmdRefs)

        for tkt_id, cmds in tickets.iteritems():
            try:
                db = self.env.get_db_cnx()

                ticket = Ticket(self.env, int(tkt_id), db)
                for cmd in cmds:
                    cmd(ticket)

                # determine sequence number...
                cnum = 0
                tm = TicketModule(self.env)
                for change in tm.grouped_changelog_entries(ticket, db):
                    if change["permanent"]:
                        cnum += 1

                ticket.save_changes(author, msg, timestamp, db, cnum + 1)
                db.commit()

                tn = TicketNotifyEmail(self.env)
                tn.notify(ticket, newticket=0, modtime=timestamp)
            except Exception, e:
                import traceback

                traceback.print_exc(file=sys.stderr)
开发者ID:nilknarf0,项目名称:extras,代码行数:58,代码来源:hook.py

示例5: __init__

# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import grouped_changelog_entries [as 别名]
    def __init__(self, project=options.project, author=AUTHOR,
                     maxage=options.maxage, url=options.url):

        self.env = open_environment(project)
        db = self.env.get_db_cnx()
        cursor = db.cursor()

        if url is None:
        	url = self.env.config.get('trac', 'base_url')

        self.env.href = Href(url)
        self.env.abs_href = Href(url)

        self.msg = MESSAGE % (maxage)
        self.now = int(time.time())

        maxtime = int(time.time()) - (60 * 60 * 24 * maxage)

        cursor.execute("SELECT id FROM ticket t, ticket_custom c " \
                       "WHERE t.status <> %s " \
        	       "AND t.changetime < %s " \
                       "AND t.id = c.ticket " \
                       "AND c.name = %s " \
                       "AND c.value = %s ", ('closed', maxtime, 'pending', '1'))
    
        rows = cursor.fetchall()

        for row in rows:
            id = row[0]
            try:
                ticket = Ticket(self.env, id, db);

                ticket['status'] = 'closed'
                ticket['pending'] = '0';

                # determine sequence number...
                cnum = 0
                tm = TicketModule(self.env)
                for change in tm.grouped_changelog_entries(ticket, db):
                	if change['permanent']:
                		cnum += 1

        
                ticket.save_changes(author, self.msg, self.now, db, cnum + 1)
                db.commit()

                print 'Closing Ticket %s (%s)\n' % (id, ticket['summary'])

                tn = TicketNotifyEmail(self.env)
                tn.notify(ticket, newticket=0, modtime=self.now)
            except Exception, e:
                import traceback
                traceback.print_exc(file=sys.stderr)
                print>>sys.stderr, 'Unexpected error while processing ticket ' \
                                   'ID %s: %s' % (id, e)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:57,代码来源:close_old_pending.py

示例6: process

# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import grouped_changelog_entries [as 别名]
    def process(self, commit, status, enable_revmap,reponame):
        self.closestatus = status
        
        msg = commit['message']
        self.env.log.debug("Processing Commit: %s", msg)
        note = "Changeset: [/changeset/%s %s]" % (commit['id'], commit['id'])
        url = "URL: %s" % commit['url']
        msg = "%s \n * %s \n * %s" % (msg, note, url)
        author = commit['author']['name']
        timestamp = datetime.now(utc)
        if int(enable_revmap):
            self.env.log.debug("adding commit %s to revmap", commit['id'])
            db = self.env.get_db_cnx()
            cursor = db.cursor()
            cursor.execute("INSERT INTO svn_revmap (svn_rev, git_hash, commit_msg) VALUES (0, %s, %s);",
                    (commit['id'], commit['message']))
            db.commit()
        
        cmd_groups = command_re.findall(msg)
        self.env.log.debug("Function Handlers: %s" % cmd_groups)

        tickets = {}
        for cmd, tkts in cmd_groups:
            funcname = self.__class__._supported_cmds.get(cmd.lower(), '')
            self.env.log.debug("Function Handler: %s" % funcname)
            if funcname:
                for tkt_id in ticket_re.findall(tkts):
                    func = getattr(self, funcname)
                    tickets.setdefault(tkt_id, []).append(func)

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

                # determine sequence number... 
                cnum = 0
                tm = TicketModule(self.env)
                for change in tm.grouped_changelog_entries(ticket, db):
                    if change['permanent']:
                        cnum += 1
                
                ticket.save_changes(author, msg, timestamp, db, cnum+1)
                db.commit()
                
                tn = TicketNotifyEmail(self.env)
                tn.notify(ticket, newticket=0, modtime=timestamp)
            except Exception, e:
                import traceback
                traceback.print_exc(file=sys.stderr)
开发者ID:danieldickison,项目名称:github-trac,代码行数:55,代码来源:hook.py

示例7: __init__

# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import grouped_changelog_entries [as 别名]
    def __init__(self, project=options.project, author=options.user,
                 rev=options.rev, url=options.url):
        self.env = open_environment(project)
        repos = self.env.get_repository()
        repos.sync()
        
        # Instead of bothering with the encoding, we'll use unicode data
        # as provided by the Trac versioncontrol API (#1310).
        try:
            chgset = repos.get_changeset(rev)
        except NoSuchChangeset:
            return # out of scope changesets are not cached
        self.author = chgset.author
        self.rev = rev
        self.msg = "(In [%s]) %s" % (rev, chgset.message)
        self.now = datetime.now(utc)

        cmd_groups = command_re.findall(self.msg)

        tickets = {}
        for cmd, tkts in cmd_groups:
            funcname = CommitHook._supported_cmds.get(cmd.lower(), '')
            if funcname:
                for tkt_id in ticket_re.findall(tkts):
                    func = getattr(self, funcname)
                    tickets.setdefault(tkt_id, []).append(func)

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

                # determine sequence number... 
                cnum = 0
                tm = TicketModule(self.env)
                for change in tm.grouped_changelog_entries(ticket, db):
                    if change['permanent']:
                        cnum += 1
                
                ticket.save_changes(self.author, self.msg, self.now, db, cnum+1)
                db.commit()
                
                tn = TicketNotifyEmail(self.env)
                tn.notify(ticket, newticket=0, modtime=self.now)
            except Exception, e:
                # import traceback
                # traceback.print_exc(file=sys.stderr)
                print>>sys.stderr, 'Unexpected error while processing ticket ' \
                                   'ID %s: %s' % (tkt_id, e)
开发者ID:Chris2Brooks,项目名称:Securiace-ERPNext-easy-installer,代码行数:54,代码来源:trac-post-commit-hook.py

示例8: _update_ticket

# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import grouped_changelog_entries [as 别名]
 def _update_ticket(ticket):
     # Determine sequence number.
     cnum = 0
     tm = TicketModule(self.env)
     db = self.env.get_db_cnx()
     for change in tm.grouped_changelog_entries(ticket, db):
         # FIXME - should this say "and change['cnum'] > cnum?
         if change['permanent']:
             cnum = change['cnum']
     # FIXME - Put something in the message?
     # FIXME - the ticket_changed method gets an author, should
     # this say "value propagation on behalf of <author>"?
     ticket.save_changes('value propagation', '', when, db, cnum+1)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:15,代码来源:valuepropagation.py

示例9: process

# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import grouped_changelog_entries [as 别名]
    def process(self, commit, status, payload):
        self.closestatus = status
        
        self.env.log.debug("Processing Commit: %s", commit['id'])
        comment = (commit['message']
            + "\n\n"
            + self.comment_template.format(commit=commit,**payload))
        self.env.log.debug("Prepared Comment: %s", comment)
        author = commit['author']['name']
        timestamp = datetime.now(utc)
        
        cmd_groups = command_re.findall(comment)
        self.env.log.debug("Function Handlers: %s" % cmd_groups)

        tickets = {}
        for cmd, tkts in cmd_groups:
            funcname = self.__class__._supported_cmds.get(cmd.lower(), '')
            self.env.log.debug("Function Handler: %s" % funcname)
            if funcname:
                for tkt_id in ticket_re.findall(tkts):
                    func = getattr(self, funcname)
                    tickets.setdefault(tkt_id, []).append(func)

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

                # determine sequence number... 
                cnum = 0
                tm = TicketModule(self.env)
                for change in tm.grouped_changelog_entries(ticket, db):
                    if change['permanent']:
                        cnum += 1
                
                ticket.save_changes(author, comment, timestamp, db, cnum+1)
                db.commit()
                
                tn = TicketNotifyEmail(self.env)
                tn.notify(ticket, newticket=0, modtime=timestamp)
            except Exception, e:
                import traceback
                traceback.print_exc(file=sys.stderr)
开发者ID:davglass,项目名称:github-trac,代码行数:48,代码来源:hook.py

示例10: handle_commit

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

    commit_log = call_git("rev-list", ["-n", "1", commit, "--pretty=medium"])
    commit_log = process_commit_log(commit_log, repo)
    commit_log = commit_log.rstrip()
    msg = to_unicode(commit_log)
    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"

            # determine sequence number...
            cnum = 0
            tm = TicketModule(env)
            for change in tm.grouped_changelog_entries(ticket, db):
                if change["permanent"]:
                    cnum += 1

            ticket.save_changes(eml, msg, now, db, cnum + 1)
            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:sammyyu,项目名称:trac-gitplugin,代码行数:46,代码来源:trac-post-receive-hook.py

示例11: on_change

# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import grouped_changelog_entries [as 别名]
    def on_change(self, env, chgset):
        self.env = env
        self.author = chgset.author
        self.rev = chgset.rev        
        self.msg = "(In [%s]) %s" % (self.rev, chgset.message)        
        self.now = chgset.date

        cmd_groups = command_re.findall(self.msg)

        tickets = {}
        for cmd, tkts in cmd_groups:
            funcname = self._supported_cmds.get(cmd.lower(), '')
            if funcname:
                for tkt_id in ticket_re.findall(tkts):
                    func = getattr(self, funcname)
                    tickets.setdefault(tkt_id, []).append(func)

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

                # determine sequence number... 
                cnum = 0
                tm = TicketModule(self.env)
                for change in tm.grouped_changelog_entries(ticket, db):
                    if change['permanent']:
                        cnum += 1
                
                ticket.save_changes(self.author, self.msg, self.now, db, cnum+1)
                db.commit()
                
                tn = TicketNotifyEmail(self.env)
                tn.notify(ticket, newticket=0, modtime=self.now)
            except Exception, e:
                # import traceback
                # traceback.print_exc(file=sys.stderr)
                print>>sys.stderr, 'Unexpected error while processing ticket ' \
                                   'ID %s: %s' % (tkt_id, e)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:44,代码来源:ticketchanger.py

示例12: handle_commit

# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import grouped_changelog_entries [as 别名]
def handle_commit(commit, env):
    from trac.ticket.notification import TicketNotifyEmail
    from trac.ticket import Ticket
    from trac.ticket.web_ui import TicketModule
    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'

            # determine sequence number...
            cnum = 0
            tm = TicketModule(env)
            for change in tm.grouped_changelog_entries(ticket, db):
                if change['permanent']:
                    cnum += 1

            ticket.save_changes(eml, msg, now, db, cnum + 1)
            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:UniIsland,项目名称:production-ready,代码行数:43,代码来源:post-receive_trac-interface_and_auto-deploy.py

示例13: process

# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import grouped_changelog_entries [as 别名]
    def process(self, commit):
        msg = commit['message']
        author = commit['author']['name']
        timestamp = datetime.now(utc)
        
        cmd_groups = command_re.findall(msg)

        tickets = {}
        for cmd, tkts in cmd_groups:
            funcname = self.__class__._supported_cmds.get(cmd.lower(), '')
            if funcname:
                for tkt_id in ticket_re.findall(tkts):
                    func = getattr(self, funcname)
                    tickets.setdefault(tkt_id, []).append(func)

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

                # determine sequence number... 
                cnum = 0
                tm = TicketModule(self.env)
                for change in tm.grouped_changelog_entries(ticket, db):
                    if change['permanent']:
                        cnum += 1
                
                ticket.save_changes(author, msg, timestamp, db, cnum+1)
                db.commit()
                
                tn = TicketNotifyEmail(self.env)
                tn.notify(ticket, newticket=0, modtime=timestamp)
            except Exception, e:
                import traceback
                traceback.print_exc(file=sys.stderr)
开发者ID:pcapriotti,项目名称:github-trac,代码行数:40,代码来源:hook.py

示例14: Ticket

# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import grouped_changelog_entries [as 别名]
for command, ticketList in commandPattern.findall(message):
	if commands.has_key(command.lower()):
		for ticketId in ticketPattern.findall(ticketList):
			tickets.setdefault(ticketId, []).append(commands[command.lower()])

for ticketId, commands in tickets.iteritems():
	db = env.get_db_cnx()

	ticket = Ticket(env, int(ticketId), db)
	for command in commands:
		command(ticket)

	# determine sequence number...
	cnum = 0
	tm = TicketModule(env)
	for change in tm.grouped_changelog_entries(ticket, db):
		c_cnum = change.get('cnum', None)
		if c_cnum and int(c_cnum) > cnum:
			cnum = int(c_cnum)

	username = authorPattern.findall(author)[0]
	now = datetime.now(utc)
	message = "(On %s [changeset:%s %s]) %s" % (refname, rev, describe_tags, message)
	ticket['branch'] = refname
	ticket.save_changes(username, message, now, db, cnum+1)
	db.commit()

	tn = TicketNotifyEmail(env)
	tn.notify(ticket, newticket=0, modtime=now)

开发者ID:20after4,项目名称:git-central,代码行数:31,代码来源:post-receive-trac.py

示例15: __init__

# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import grouped_changelog_entries [as 别名]
    def __init__(self, project=options.project, author=options.user,
                 rev=options.rev, url=options.url):
        self.init_env( project )
        
        repos = self.env.get_repository()
        repos.sync()
        # Instead of bothering with the encoding, we'll use unicode data
        # as provided by the Trac versioncontrol API (#1310).
        try:
            chgset = repos.get_changeset(rev)
        except NoSuchChangeset:
            return # out of scope changesets are not cached
        self.author = chgset.author
        self.rev = rev
        self.msg = "(In [%s]) %s" % (rev, chgset.message)
        self.now = int(time.time())

        cmd_groups = command_re.findall(self.msg)
        log ("cmd_groups:%s", cmd_groups)
        tickets = {}
        for cmd, tkts, xxx1, xxx2 in cmd_groups:
            log ("cmd:%s, tkts%s ", cmd, tkts)
            funcname = _supported_cmds.get(cmd.lower(), '')
            if funcname:
                for tkt_id, spent in ticket_re.findall(tkts):
                    func = getattr(self, funcname)
                    lst = tickets.setdefault(tkt_id, [])
                    lst.append([func, spent])
                    

        for tkt_id, vals in tickets.iteritems():
            log ("tkt_id:%s, vals%s ", tkt_id, vals)
            spent_total = 0.0
            try:
                db = self.env.get_db_cnx()
                
                ticket = Ticket(self.env, int(tkt_id), db)
                for (cmd, spent) in vals:
                    cmd(ticket)
                    if spent:
                        spent_total += float(spent)

                # determine sequence number... 
                cnum = 0
                tm = TicketModule(self.env)
                for change in tm.grouped_changelog_entries(ticket, db):
                    if change['permanent']:
                        cnum += 1
                if spent_total:
                    self._setTimeTrackerFields(ticket, spent_total)
                ticket.save_changes(self.author, self.msg, self.now, db, cnum+1)
                db.commit()

                tn = TicketNotifyEmail(self.env)
                tn.notify(ticket, newticket=0, modtime=self.now)
            except Exception, e:
                # import traceback
                # traceback.print_exc(file=sys.stderr)
                log('Unexpected error while processing ticket ' \
                                   'ID %s: %s' % (tkt_id, e))
                print>>sys.stderr, 'Unexpected error while processing ticket ' \
                                   'ID %s: %s' % (tkt_id, e)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:64,代码来源:trac-post-commit.py


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