本文整理匯總了Python中webkitpy.tool.bot.ircbot.IRCBot類的典型用法代碼示例。如果您正苦於以下問題:Python IRCBot類的具體用法?Python IRCBot怎麽用?Python IRCBot使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了IRCBot類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: SheriffBot
class SheriffBot(AbstractQueue, StepSequenceErrorHandler):
name = "webkitbot"
watchers = AbstractQueue.watchers + ["[email protected]", "[email protected]"]
# AbstractQueue methods
def begin_work_queue(self):
AbstractQueue.begin_work_queue(self)
self._sheriff = Sheriff(self._tool, self)
self._irc_bot = IRCBot(self.name, self._tool, self._sheriff, irc_commands)
self._tool.ensure_irc_connected(self._irc_bot.irc_delegate())
def work_item_log_path(self, failure_map):
return None
def _is_old_failure(self, revision):
return self._tool.status_server.svn_revision(revision)
def next_work_item(self):
self._irc_bot.process_pending_messages()
return
def process_work_item(self, failure_map):
return True
def handle_unexpected_error(self, failure_map, message):
_log.error(message)
# StepSequenceErrorHandler methods
@classmethod
def handle_script_error(cls, tool, state, script_error):
# Ideally we would post some information to IRC about what went wrong
# here, but we don't have the IRC password in the child process.
pass
示例2: test_parse_command_and_args
def test_parse_command_and_args(self):
tool = MockTool()
bot = IRCBot("sheriffbot", tool, Sheriff(tool, MockSheriffBot()), irc_command.commands)
self.assertEqual(bot._parse_command_and_args(""), (Eliza, [""]))
self.assertEqual(bot._parse_command_and_args(" "), (Eliza, [""]))
self.assertEqual(bot._parse_command_and_args(" hi "), (irc_command.Hi, []))
self.assertEqual(bot._parse_command_and_args(" hi there "), (irc_command.Hi, ["there"]))
示例3: run
def run(message):
tool = MockTool()
tool.ensure_irc_connected(None)
bot = IRCBot("sheriffbot", tool, Sheriff(tool, MockSheriffBot()), irc_command.commands)
bot._message_queue.post(["mock_nick", message])
bot.process_pending_messages()
示例4: begin_work_queue
def begin_work_queue(self):
AbstractQueue.begin_work_queue(self)
self._sheriff = Sheriff(self._tool, self)
self._irc_bot = IRCBot("perfalizer", self._tool, self._sheriff, self._commands)
self._tool.ensure_irc_connected(self._irc_bot.irc_delegate())
示例5: begin_work_queue
def begin_work_queue(self):
self._last_svn_revision = int(self._tool.scm().head_svn_revision())
self._irc_bot = IRCBot(self.name, self._tool, Agent(self._tool, self), self._commands)
self._tool.ensure_irc_connected(self._irc_bot.irc_delegate())
示例6: NewCommitBot
class NewCommitBot(AbstractQueue, StepSequenceErrorHandler):
name = "new-commit-bot"
watchers = AbstractQueue.watchers + ["[email protected]"]
_commands = {
"ping": PingPong,
"restart": Restart,
}
# AbstractQueue methods
def begin_work_queue(self):
AbstractQueue.begin_work_queue(self)
self._last_svn_revision = int(self._tool.scm().head_svn_revision())
self._irc_bot = IRCBot('WKR', self._tool, None, self._commands)
self._tool.ensure_irc_connected(self._irc_bot.irc_delegate())
def work_item_log_path(self, failure_map):
return None
def next_work_item(self):
self._irc_bot.process_pending_messages()
_log.info('Last SVN revision: %d' % self._last_svn_revision)
_log.info('Updating checkout')
self._update_checkout()
_log.info('Obtaining new SVN revisions')
revisions = self._new_svn_revisions()
_log.info('Obtaining commit logs for %d revisions' % len(revisions))
for revision in revisions:
commit_log = self._tool.scm().svn_commit_log(revision)
self._tool.irc().post(self._summarize_commit_log(commit_log).encode('ascii', 'ignore'))
return
def process_work_item(self, failure_map):
return True
def _update_checkout(self):
tool = self._tool
tool.executive.run_and_throw_if_fail(tool.deprecated_port().update_webkit_command(), quiet=True, cwd=tool.scm().checkout_root)
def _new_svn_revisions(self):
scm = self._tool.scm()
current_head = int(scm.head_svn_revision())
first_new_revision = self._last_svn_revision + 1
self._last_svn_revision = current_head
return range(max(first_new_revision, current_head - 20), current_head + 1)
_patch_by_regex = re.compile(r'^Patch\s+by\s+(?P<author>.+?)\s+on(\s+\d{4}-\d{2}-\d{2})?\n?', re.MULTILINE | re.IGNORECASE)
_rollout_regex = re.compile(r'(rolling out|reverting) (?P<revisions>r?\d+((,\s*|,?\s*and\s+)?r?\d+)*)\.?\s*', re.MULTILINE | re.IGNORECASE)
_requested_by_regex = re.compile(r'^\"?(?P<reason>.+?)\"? \(Requested\s+by\s+(?P<author>.+?)\s+on\s+#webkit\)\.', re.MULTILINE | re.IGNORECASE)
_bugzilla_url_regex = re.compile(r'http(s?)://bugs\.webkit\.org/show_bug\.cgi\?id=(?P<id>\d+)', re.MULTILINE)
_trac_url_regex = re.compile(r'http(s?)://trac.webkit.org/changeset/(?P<revision>\d+)', re.MULTILINE)
@classmethod
def _summarize_commit_log(self, commit_log, committer_list=CommitterList()):
patch_by = self._patch_by_regex.search(commit_log)
commit_log = self._patch_by_regex.sub('', commit_log, count=1)
rollout = self._rollout_regex.search(commit_log)
commit_log = self._rollout_regex.sub('', commit_log, count=1)
requested_by = self._requested_by_regex.search(commit_log)
commit_log = self._bugzilla_url_regex.sub(r'https://webkit.org/b/\g<id>', commit_log)
commit_log = self._trac_url_regex.sub(r'https://trac.webkit.org/r\g<revision>', commit_log)
for contributor in committer_list.contributors():
if not contributor.irc_nicknames:
continue
name_with_nick = "%s (%s)" % (contributor.full_name, contributor.irc_nicknames[0])
if contributor.full_name in commit_log:
commit_log = commit_log.replace(contributor.full_name, name_with_nick)
for email in contributor.emails:
commit_log = commit_log.replace(' <' + email + '>', '')
else:
for email in contributor.emails:
commit_log = commit_log.replace(email, name_with_nick)
lines = commit_log.split('\n')[1:-2] # Ignore lines with ----------.
firstline = re.match(r'^(?P<revision>r\d+) \| (?P<email>[^\|]+) \| (?P<timestamp>[^|]+) \| [^\n]+', lines[0])
assert firstline
author = firstline.group('email')
if patch_by:
author = patch_by.group('author')
linkified_revision = 'https://trac.webkit.org/%s' % firstline.group('revision')
lines[0] = '%s by %s' % (linkified_revision, author)
if rollout:
if requested_by:
author = requested_by.group('author')
contributor = committer_list.contributor_by_irc_nickname(author)
if contributor:
author = "%s (%s)" % (contributor.full_name, contributor.irc_nicknames[0])
#.........這裏部分代碼省略.........