-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_traffic.py
37 lines (24 loc) · 918 Bytes
/
check_traffic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import os
import webbrowser
from dotenv import load_dotenv
from github import Github
def get_github_repositories(username, token):
g = Github(token)
user = g.get_user(username)
repos = user.get_repos()
repo_names = [repo.name for repo in repos]
return repo_names
def check_github_traffic_in_browser(username, token, chrome_path):
repos = get_github_repositories(username, token)
webbrowser.register("chrome", None, webbrowser.BackgroundBrowser(chrome_path))
for i, repo in enumerate(repos):
url = f'https://github.com/{username}/{repo}/graphs/traffic'
webbrowser.get(using='chrome').open(url )
def main():
load_dotenv()
token = os.getenv('GITHUB_TOKEN')
username = os.getenv('GITHUB_USERNAME')
chrome_path = os.getenv("CHROME_PATH")
check_github_traffic_in_browser(username, token, chrome_path)
if __name__ == '__main__':
main()