def f_list_git_pull_requests(phenny, input): prList = web.json(web.get("http://github.com/api/v2/json/pulls/%s/open" % phenny.config.github_project)) pulls = prList["pulls"] if len(pulls) == 0: phenny.say("There are no open pull requests in %s" % phenny.config.github_project) else: phenny.say("%s open pull request%s:" % (len(pulls), "s" if len(pulls) != 1 else "")) for issue in pulls: title = issue["title"][:60] if len(issue["title"]) > 60: title += "..." phenny.say("%s: %s %s" % (issue["user"]["login"], title, shorten(issue["html_url"])))
def _find_github_file(phenny, branch, fname): bag = web.json(web.get("https://github.com/api/v2/json/blob/all/%s/%s" % (phenny.config.github_project, branch)))["blobs"] outlist = [f for f in bag.keys() if re.search(fname.lower(), f.lower())] outlist.sort() if outlist: phenny.say ("Found %s matching file(s) in the %s branch. First %s are:" % (len(outlist), branch, min(5, len(outlist)))) for found in outlist[:5]: fnd = found.strip("/") url = "https://github.com/%s/tree/%s/%s" % (phenny.config.github_project, branch, fnd) url = shorten(url) phenny.say("%s %s" % (found, url))
def f_search_confluence(self, input): print "Wiki search", input query = input.group(1) if not input.sender in self.config.jira_channels and not input.owner: return server = xmlrpclib.ServerProxy(self.config.confluence_baseurl) rpc = server.confluence1 auth = rpc.login(self.config.confluence_username, self.config.confluence_password) results = rpc.search(auth, query, self.config.confluence_searchresults) self.say ("%s results found. Note: Results limited to %s" % (len(results), self.config.confluence_searchresults)) for page in results[:self.config.confluence_searchresults]: self.say ('"%s": %s' % (page["title"], shorten(page["url"])))
def f_search_confluence(self, input): print "Wiki search", input query = input.group(1) if not input.sender in self.config.jira_channels and not input.owner: return server = xmlrpclib.ServerProxy(self.config.confluence_baseurl) rpc = server.confluence1 auth = rpc.login(self.config.confluence_username, self.config.confluence_password) results = rpc.search(auth, query, self.config.confluence_searchresults) self.say("%s results found. Note: Results limited to %s" % (len(results), self.config.confluence_searchresults)) for page in results[:self.config.confluence_searchresults]: self.say('"%s": %s' % (page["title"], shorten(page["url"])))
def _find_github_commit(phenny, query): try: res = gh.commits.show(phenny.config.github_project, sha=query) print res phenny.say("%s by %s: %s %s" % (res.id[:7], res.author["name"], res.message[:60], shorten("https://github.com" + res.url))) except: print "Couldn't find %s" % query pass
def lmgt(phenny, input): """Queries Google for the specified input.""" a= "http://lmgtfy.com/?q=download+solr" query = input.group(2) url = "http://lmgtfy.com/?q=%s" % web.urllib.quote(query.encode('utf-8')) phenny.say("Let me google that for you: %s" % shorten(url))
def _find_github_tag(phenny, fname, types=("c", "f", "t")): import ctags from ctags import CTags, TagEntry t = CTags(phenny.config.tagfile) e = TagEntry() if not t.find(e, fname, ctags.TAG_PARTIALMATCH): phenny.say("Could not find any tags matching %s" % fname) return tags = [getTag(e)] while t.findNext(e): if e["kind"] in types: tags.append(getTag(e)) newtags = [] for e in tags: if e not in newtags: newtags.append(e) phenny.say("Found %s possible matches. Displaying %s" % (len(newtags), min(len(newtags), 5))) for entry in tags[:5]: url = "https://github.com/%s/tree/%s/%s" % (phenny.config.github_project, "master", entry["file"]) if entry["lineNumber"]: url += "#%s" % entry["lineNumber"] url = shorten(url) phenny.say("%s (%s) found in %s: %s" % (entry["pattern"], entry["kind"], entry["file"], url))