def new_bug_notify_ircbot_process_hook(config, log, irc): """ Monitor LaunchPad for new bugs, and post to irc. """ lp_ids = [] first_run = True while True: log.debug('checking LaunchPad for new bugs') lp = Launchpad.login_anonymously('ius-tools', 'production') ius = lp.projects.search(text='ius')[0] tasks = ius.searchTasks() for task in tasks: bugid = task.bug.id if first_run and bugid not in lp_ids: # just append all ids to the list log.debug('Adding %s to known ids' % bugid) lp_ids.append(bugid) elif not first_run and bugid not in lp_ids: # if not first run post to channel url = shorten_url(unicode(task.web_link)) reply = "New %s - %s" % (task.title, url) irc.send_to_channel(reply) log.debug('Adding %s to known ids' % bugid) lp_ids.append(bugid) first_run = False sleep(300)
def get_package_repo(package): """ Get a package's bzr repo URL. """ lp = Launchpad.login_anonymously('ius-tools', 'production') ius = lp.projects.search(text='ius')[0] # Package Search pkg = lp.branches.getByUrl(url='lp:~ius-coredev/ius/%s' % package) if pkg: out_txt = '%s' % shorten_url(pkg.web_link) else: raise IUSToolsArgumentError, '%s does not exist' % package return out_txt
def lookup_bug_info_ircbot_parsemsg_hook(config, log, irc, poll_result): """ Parse the result of irc.poll() and look for txt matching LaunchPad bug id's. If found, print bug info to the channel. """ (from_nick, from_chan, msg, dest) = poll_result lp = Launchpad.login_anonymously('ius-tools', 'production') # don't respond to ourself: if from_nick == irc.nick: return bug_ids = [] res = re.findall('#[0-9]+', msg) for match in res: bug_ids.append(match.lstrip('#')) res = re.findall('https:\/\/bugs\.launchpad\.net\/ius\/\+bug\/[0-9]+', msg) for match in res: _id = re.sub('https:\/\/bugs\.launchpad\.net\/ius\/\+bug\/', '', match) if _id: bug_ids.append(_id) for _id in bug_ids: log.debug('looking up bug #%s' % _id) try: bug = lp.bugs[int(_id)] except KeyError, e: log.debug('LaunchPad bug %s does not exist' % _id) reply = "I tried to lookup LP#%s, but it doesn't exist." % _id irc.send_to_channel(reply) continue url = shorten_url(unicode(bug.web_link)) reply = "LP#%s - %s - %s" % (_id, bug.title, url) irc.send_to_channel(reply)
def get_bug(bug): """ Get information for a bug. """ lp = Launchpad.login_anonymously('ius-tools', 'production') bug_id = int(bug.lstrip('LP#').strip()) log.debug('looking up bug #%s' % bug_id) try: bug = lp.bugs[int(bug_id)] except KeyError, e: raise IUSToolsArgumentError, \ 'LaunchPad bug %s does not exist' % bug_id url = shorten_url(unicode(bug.web_link)) out_txt = "LP#%s - %s - %s" % (bug_id, bug.title, url) return out_txt def get_package_repo(package): """ Get a package's bzr repo URL. """ lp = Launchpad.login_anonymously('ius-tools', 'production') ius = lp.projects.search(text='ius')[0] # Package Search pkg = lp.branches.getByUrl(url='lp:~ius-coredev/ius/%s' % package) if pkg:
return out_txt def get_bug(bug): """ Get information for a bug. """ lp = Launchpad.login_anonymously('ius-tools', 'production') bug_id = int(bug.lstrip('LP#').strip()) log.debug('looking up bug #%s' % bug_id) try: bug = lp.bugs[int(bug_id)] except KeyError, e: raise IUSToolsArgumentError, \ 'LaunchPad bug %s does not exist' % bug_id url = shorten_url(unicode(bug.web_link)) out_txt = "LP#%s - %s - %s" % (bug_id, bug.title, url) return out_txt def get_package_repo(package): """ Get a package's bzr repo URL. """ lp = Launchpad.login_anonymously('ius-tools', 'production') ius = lp.projects.search(text='ius')[0] # Package Search pkg = lp.branches.getByUrl(url='lp:~ius-coredev/ius/%s' % package) if pkg: out_txt = '%s' % shorten_url(pkg.web_link)