Exemplo n.º 1
0
Arquivo: gist.py Projeto: Xobb/hexahub
def create_gist(token, endpoint, uri, paths, public=False, description=None):
    data = {}

    data["files"] = {}
    for path in paths:
        name = os.path.basename(path)
        content = file(path, "r").read()
        data["files"][name] = {"content": content}

    if description:
        data["description"] = description

    data["public"] = public

    conn = Connection(token, endpoint)
    response = conn.send("POST", uri, params={}, data=json.dumps(data))

    return response.parsed
Exemplo n.º 2
0
Arquivo: list.py Projeto: Xobb/hexahub
        elif opt in ('-n', '--noauth'):
            auth = False

    token = os.environ.get('OCTOHUB_TOKEN', None)
    if not token and auth:
        fatal('OCTOHUB_TOKEN is required, override with --noauth')

    if not auth:
        token = None

    if not len(args) == 1:
        usage()

    endpoint = os.environ.get('OCTOHUB_ENDPOINT', 'https://github.com/api/v3')

    conn = Connection(token, endpoint)

    if '/' in args[0]:
        owner = args[0].split('/')[0]
        repos.append(args[0].split('/')[1])
    else:
        owner = args[0]
        try:
            repos = get_repos(conn, '/orgs/%s/repos' % owner)
        except ResponseError, e:
            repos = get_repos(conn, '/users/%s/repos' % owner)

    for repo in repos:
        response = conn.send('GET', '/repos/%s/%s/pulls' % (owner, repo))
        if response.parsed:
            print '%s/%s\n' % (owner, repo)