Compare commits
No commits in common. "c29ad2f5be32b9611c650841fd5ddc4bada1757f" and "a15b5ffda0cb953f230cf1f0c8a4c931f5fae0ea" have entirely different histories.
c29ad2f5be
...
a15b5ffda0
@ -56,7 +56,8 @@ class GitHubApi:
|
|||||||
"""Parse headers to update rate limits."""
|
"""Parse headers to update rate limits."""
|
||||||
self.rate_reset = datetime.fromtimestamp(int(headers['x-ratelimit-reset']))
|
self.rate_reset = datetime.fromtimestamp(int(headers['x-ratelimit-reset']))
|
||||||
self.rate_remaining = int(headers['x-ratelimit-remaining'])
|
self.rate_remaining = int(headers['x-ratelimit-remaining'])
|
||||||
logger.info(f'{self.rate_remaining} calls remaining until {self.rate_reset} ({self.rate_reset - datetime.now()})')
|
logger.info(f'{self.rate_remaining} calls remaining until {self.rate_reset}')
|
||||||
|
|
||||||
|
|
||||||
def get_events(self, page=None):
|
def get_events(self, page=None):
|
||||||
"""Fetch GitHub events."""
|
"""Fetch GitHub events."""
|
||||||
|
16
main.py
16
main.py
@ -1,18 +1,16 @@
|
|||||||
"""GitMon"""
|
"""GitMon"""
|
||||||
import time
|
|
||||||
from loguru import logger
|
|
||||||
from gitmon.api import GitHubApi
|
from gitmon.api import GitHubApi
|
||||||
from gitmon.logger import setup_logger
|
from gitmon.logger import setup_logger
|
||||||
|
|
||||||
from config import token
|
from config import token
|
||||||
|
|
||||||
|
|
||||||
def log_event(event):
|
def print_event(event):
|
||||||
event_type = event.get('type')
|
event_type = event.get('type')
|
||||||
repo = event.get('repo')
|
repo = event.get('repo')
|
||||||
actor = event.get('actor')
|
actor = event.get('actor')
|
||||||
|
|
||||||
logger.info(f'{event_type}:\t{repo["name"]}, {actor["login"]}')
|
print(f'{event_type}:\t{repo["name"]}, {actor["login"]}')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@ -20,13 +18,9 @@ def main():
|
|||||||
setup_logger()
|
setup_logger()
|
||||||
api = GitHubApi(token)
|
api = GitHubApi(token)
|
||||||
|
|
||||||
while True:
|
events = api.get_events()
|
||||||
events = api.get_events()
|
for event in events:
|
||||||
for event in events:
|
print_event(event)
|
||||||
if event['type'] == 'CreateEvent':
|
|
||||||
log_event(event)
|
|
||||||
|
|
||||||
time.sleep(10)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user