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