Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions collectoss/application/cli/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from datetime import datetime
import httpx
from collections import Counter
from collectoss.util.keys import mask_key

from collectoss.application.cli import test_connection, test_db_connection

Expand All @@ -19,9 +20,16 @@ def cli():
pass

@cli.command("api-keys")
@click.option(
"--show-keys",
is_flag=True,
default=False,
help="Show full API keys instead of masking them.",
)

@test_connection
@test_db_connection
def update_api_key():
def update_api_key(show_keys):
"""
Get the ratelimit of Github API keys
"""
Expand Down Expand Up @@ -63,24 +71,24 @@ def update_api_key():

graphql_requests = str(graphql_key_data['requests_remaining']).center(len(graphql_request_header))
graphql_reset_time = str(epoch_to_local_time_with_am_pm(graphql_key_data["reset_epoch"])).center(len(graphql_reset_header))

print(f"{key} | {core_requests} | {core_reset_time} | {graphql_requests} | {graphql_reset_time} |")
display_key = key if show_keys else mask_key(key)
print(f"{display_key} | {core_requests} | {core_reset_time} | {graphql_requests} | {graphql_reset_time} |")

valid_key_list = [x[0] for x in valid_key_data]
duplicate_keys = find_duplicates(valid_key_list)
if len(duplicate_keys) > 0:
print("\n\nWARNING: There are duplicate keys this will slow down collection")
print("Duplicate keys".center(40))
for key in duplicate_keys:
print(key)
print(key if show_keys else mask_key(key))


if len(invalid_keys) > 0:
invalid_key_header = "Invalid Keys".center(40)
print("\n")
print(invalid_key_header)
for key in invalid_keys:
print(key)
print(key if show_keys else mask_key(key))
print("")


Expand Down
Loading