コード例 #1
0
def prepare_github(github_user, github_repo, token=None):

    if token:
        output("Authenticating to GitHub using token\n")
        github = Github(token)
    else:
        output("Log into Gituhub as {0}\n".format(github_user))
        while True:
            github_password = getpass.getpass("Github password: "******"Bad credentials, try again.\n")
        github = Github(github_user, github_password)

    github_user = github.get_user()

    # If the project name is specified as owner/project, assume that it's owned by either
    # a different user than the one we have credentials for, or an organization.

    if "/" in github_repo:
        gh_user, gh_repo = github_repo.split('/')
        try:
            github_owner = github.get_user(gh_user)
        except GithubException:
            try:
                github_owner = github.get_organization(gh_user)
            except GithubException:
                github_owner = github_user
    else:
        github_owner = github_user

    gh_repo_obj = github_owner.get_repo(gh_repo)
    return gh_repo_obj
コード例 #2
0
def prepare_github(github_user, github_repo, token=None):

    if token:
        output("Authenticating to GitHub using token\n")
        github = Github(token)
    else:
        output("Log into Gituhub as {0}\n".format(github_user))
        while True:
            github_password = getpass.getpass("Github password: "******"Bad credentials, try again.\n")
        github = Github(github_user, github_password)

    github_user = github.get_user()

    # If the project name is specified as owner/project, assume that it's owned by either
    # a different user than the one we have credentials for, or an organization.

    if "/" in github_repo:
        gh_user, gh_repo = github_repo.split('/')
        try:
            github_owner = github.get_user(gh_user)
        except GithubException:
            try:
                github_owner = github.get_organization(gh_user)
            except GithubException:
                github_owner = github_user
    else:
        github_owner = github_user

    gh_repo_obj = github_owner.get_repo(gh_repo)
    return gh_repo_obj
コード例 #3
0
    def test_get_user(self):
        user = '******'

        results = github.get_user(user)

        self.assertNotEqual(results, None)
        self.assertIsInstance(results, dict)
        self.assertTrue('login' in results)
        self.assertEqual(results['login'], user)
コード例 #4
0
    def test_get_user(self):
        user = '******'

        results = github.get_user(user)

        self.assertNotEqual(results, None)
        self.assertIsInstance(results, dict)
        self.assertTrue('login' in results)
        self.assertEqual(results['login'], user)
コード例 #5
0
def get_Config(filename):

    fileType = filename.split('.')
    fileType1 = fileType[1]
    if (fileType1 == 'yml' or fileType1 == 'json'):
        myRepo = str(sys.argv[1])
        github = Github()
        user = github.get_user("abhiCITI1")
        repositories = user.get_repos()

        for repo in repositories:
            repostoryName = "https://github.com/" + str(repo.full_name)

            if (repostoryName == myRepo):
                try:
                    file_content = repo.get_contents(filename, ref='master')
                    file_data = base64.b64decode(file_content.content)
                    return str(file_data)
                except Exception:
                    return "File is invalid..Not found in your Github repository."
    else:
        return "File is invalid..Not found in your Github repository."
コード例 #6
0
ファイル: enarxbot.py プロジェクト: matt-ross16/bot
 def query(cls, github, repo, pr):
     data = graphql(cls.QUERY, owner=repo.owner.login, repo=repo.name, pr=pr.number)
     for x in data["repository"]["pullRequest"]["suggestedReviewers"]:
         reviewer = github.get_user(x["reviewer"]["login"])
         yield cls(reviewer, x["isAuthor"], x["isCommenter"])
コード例 #7
0
def test_get_user():
    user_info = github.get_user("shibataka000")
    assert user_info["login"] == "shibataka000"
コード例 #8
0
ファイル: github_demo.py プロジェクト: mccalltd/py_hacking
"""Demo use of github module.
"""

import github as gh
from pprint import pprint


separator = '-' * 80

print('\nInfo for mccalltd:\n', separator, sep='')
user = gh.get_user('mccalltd')
pprint({'name': user['name'],
        'followers': user['followers']})

print('\nRepos for mccalltd:\n', separator, sep='')
for r in gh.get_repos('mccalltd'):
    pprint({'name': r['name'],
            'description': r['description']})

print('\nOpen pull requests for rails/rails:\n', separator, sep='')
for r in gh.get_pull_requests('rails', 'rails'):
    pprint({'body': r['body'],
            'submitter': r['user']['login'],
            'commit_id': r['head']['sha']})