Giter Site home page Giter Site logo

niklasrosenstein / python-github-bot-api Goto Github PK

View Code? Open in Web Editor NEW
19.0 3.0 7.0 6.23 MB

API for creating GitHub bots and webhooks in Python.

Home Page: https://niklasrosenstein.github.io/python-github-bot-api/

License: Other

Python 100.00%
python github library

python-github-bot-api's Introduction

python-github-bot-api

PyPI - Python Version

A thin Python library for creating GitHub bots and webhooks in Python with PyGithub.

from github import Github
from github_bot_api import GithubApp
from pathlib import Path

app = GithubApp(
    user_agent='my-bot/0.0.0',
    app_id="67890",
    private_key=Path("app-private.key").read_text(),
)

client: Github = app.installation_client(12345)

For more examples, check out the documentation.

python-github-bot-api's People

Contributors

bobotig avatar niklasrosenstein avatar testworksau avatar timgates42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

python-github-bot-api's Issues

The upgrade to PyJWT > 2.0 has resulted in an exception when attempting to decode a string

The following issue was caused by c8eac8c

PyJWT returns an already-decoded string now instead of bytes:
jpadilla/pyjwt#513

Traceback (most recent call last):
  File "C:\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\devel\venvs\gh-repo-keeper\lib\site-packages\githubrepokeeper\__main__.py", line 115, in <module>
    github_api = github_app.installation_client(
  File "C:\devel\venvs\gh-repo-keeper\lib\site-packages\github_bot_api\app.py", line 211, in installation_client
    token = self.installation_token(installation_id).value
  File "C:\devel\venvs\gh-repo-keeper\lib\site-packages\github_bot_api\app.py", line 189, in installation_token
    return self.get_installation_token_supplier(installation_id)()
  File "C:\devel\venvs\gh-repo-keeper\lib\site-packages\github_bot_api\token.py", line 86, in __call__
    self._cached_token = self._new_token()
  File "C:\devel\venvs\gh-repo-keeper\lib\site-packages\github_bot_api\token.py", line 145, in _new_token
    data = self.requestor(self.app_jwt().auth_header, self.installation_id)
  File "C:\devel\venvs\gh-repo-keeper\lib\site-packages\github_bot_api\token.py", line 86, in __call__
    self._cached_token = self._new_token()
  File "C:\devel\venvs\gh-repo-keeper\lib\site-packages\github_bot_api\token.py", line 116, in _new_token
    return create_jwt(self.app_id, self.expires_in, self.private_key)
  File "C:\devel\venvs\gh-repo-keeper\lib\site-packages\github_bot_api\token.py", line 61, in create_jwt
    token = jwt.encode(payload, private_key, algorithm='RS256').decode('ascii')
AttributeError: 'str' object has no attribute 'decode'

Support PyJWT >2

There's a conflict with PyGitHub >=1.55 and this library which depends on PyJWT<2.0.0.

It would be good if this library can be updated to use a newer version of PyJWT so that we can take the latest PyGitHub version.

ERROR: Cannot install <packagename> because these package versions have conflicting dependencies.

The conflict is caused by:
    pygithub 1.55 depends on pyjwt>=2.0
    github-bot-api 0.3.3 depends on PyJWT<2.0.0 and >=1.7.1
    pygithub 1.55 depends on pyjwt>=2.0
    github-bot-api 0.3.1 depends on PyJWT<2.0.0 and >=1.7.1
    pygithub 1.55 depends on pyjwt>=2.0
    github-bot-api 0.3.0 depends on PyJWT<2.0.0 and >=1.7.1
    pygithub 1.55 depends on pyjwt>=2.0
    github-bot-api 0.2.0 depends on PyJWT<2.0.0 and >=1.7.1
    pygithub 1.55 depends on pyjwt>=2.0
    github-bot-api 0.1.0 depends on PyJWT<2.0.0 and >=1.7.1

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies
ERROR: 1

Support configuration of `per_page` in the `installation_client`

It would be good if we could initialise the installation client with the per_page parameter.

We pass this through to a normal PyGitHub client as follows:

github_api = Github(login_or_token=token, per_page=100)

It would be great if we could pass this through via the installation_client like we can with a regular PyGitHub client, rather than having to set it after the client has been created:

github_api.per_page = 100

Support passing the retry object into the installation_client

Thanks for the great work on this library; I've been experimenting with it today.

Since PyGitHub 1.43.6, support for requests -> urllib3 retry has been available.

We define our Retry method to retry on a range of different status's, as follows:

status_forcelist = (
    HTTPStatus.INTERNAL_SERVER_ERROR,
    HTTPStatus.BAD_GATEWAY,
    HTTPStatus.SERVICE_UNAVAILABLE,
    HTTPStatus.GATEWAY_TIMEOUT
)

retry = Retry(
    total=10,
    connect=10,
    read=10,
    backoff_factor=0.1,
    status_forcelist=status_forcelist
)

We pass this through to PyGitHub as follows:

github_api = Github(login_or_token=token, retry=retry)

It would be great if we could pass this through via the installation_client.

No license

Hey @NiklasRosenstein,

I would like to use this package at Udemy, but it currently has no license.

If you are okay with the library being used in a commercial setting, would you mind adding a suitable license?

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.