Compare commits
3 Commits
2e2756db07
...
fb7c7e7bdf
Author | SHA1 | Date | |
---|---|---|---|
fb7c7e7bdf | |||
0f323c6cfe | |||
ad857ab719 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,3 +3,5 @@ venv/
|
||||
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
||||
config.py
|
@ -8,13 +8,15 @@ from requests.packages.urllib3.util.retry import Retry
|
||||
|
||||
|
||||
class GitHubApi:
|
||||
def __init__(self, headers=None, proxy=None):
|
||||
def __init__(self, token=None, headers=None, proxy=None):
|
||||
self.base_url = 'https://api.github.com'
|
||||
self.session = requests.Session()
|
||||
|
||||
retries = Retry(total=3, backoff_factor=1)
|
||||
self.session.mount('https://', HTTPAdapter(max_retries=retries))
|
||||
|
||||
if token:
|
||||
self.session.headers.update({'Authorization': f'Bearer {token}'})
|
||||
if headers:
|
||||
self.session.headers.update(headers)
|
||||
if proxy:
|
||||
|
4
main.py
4
main.py
@ -2,6 +2,8 @@
|
||||
from loguru import logger
|
||||
from gitmon.api import GitHubApi
|
||||
|
||||
from config import token
|
||||
|
||||
|
||||
def print_event(event):
|
||||
event_type = event.get('type')
|
||||
@ -14,7 +16,7 @@ def print_event(event):
|
||||
def main():
|
||||
"""Main entry point."""
|
||||
|
||||
api = GitHubApi()
|
||||
api = GitHubApi(token)
|
||||
|
||||
events = api.get_events()
|
||||
for event in events:
|
||||
|
Loading…
Reference in New Issue
Block a user