def create_issue(task): api = GithubAPIGateway(token=os.environ["GITHUB_TOKEN"]) username = api.call("user")[0]["login"] body = "### {0}\n___\n\n{1}".format(task["permalink"].encode("utf-8"), task["description"].encode("utf-8")) owner, repo = Helper.owner_and_repo() issue = api.call( "create_issue", owner=owner, repo=repo, data={"title": task["title"], "assignee": username, "body": body} )[0] return issue
def _create_auth_info(self): webbrowser.open('https://www.wrike.com/oauth2/authorize?client_id={0}&response_type=code'.format(os.environ['WRIKE_CLIENT_ID'])) self._httpd = QuickSocketServer() self._serverthread = ServerThread(self._httpd) self._serverthread.start() while self._httpd.authentication_code is None: pass authentication_code = self._httpd.authentication_code if self._redirect is not None: self.redirect(self._redirect) owner, repo = Helper.owner_and_repo() auth_info = super(WrikeAPIGateway, self).call('get_token', params={ 'client_id': os.environ['WRIKE_CLIENT_ID'], 'client_secret': os.environ['WRIKE_CLIENT_SECRET'], 'code': authentication_code })[0] with open(self._get_auth_file_filepath(), 'w') as outfile: json.dump(auth_info, outfile) return auth_info
from GithubAPIGateway import GithubAPIGateway import Helper import os import sys import argparse import webbrowser parser = argparse.ArgumentParser() parser.add_argument("-o", "--open", action="store_true") args = parser.parse_args() api = GithubAPIGateway(token=os.environ['GITHUB_TOKEN']) owner, repo = Helper.owner_and_repo() branch = str(Helper.current_branch()) prs = api.call('list_pr', owner=owner, repo=repo, data={ 'head': branch })[0] url = None for pr in prs: if pr['head']['ref'] == branch: url = pr['html_url'] break if url is not None: print url if args.open: webbrowser.open(url) else: print "No PRs on this branch"
def __init__(self): self._username, self._project = Helper.owner_and_repo() self._api = CircleCiAPIGateway(token=os.environ['CIRCLE_TOKEN'])
def __init__(self): self._owner, self._repo = Helper.owner_and_repo() self._api = GithubAPIGateway(token=os.environ['GITHUB_TOKEN']) self._cache = {}