-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathgithub_rate_limit.py
31 lines (24 loc) · 989 Bytes
/
github_rate_limit.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
# github_rate_limit.py
# Dan Wallach <[email protected]>
# Available subject to the Apache 2.0 License
# https://www.apache.org/licenses/LICENSE-2.0
import argparse
from github_config import *
from github_scanner import *
parser = argparse.ArgumentParser(description='Prints your GitHub API rate limit stats.')
parser.add_argument('--token',
nargs=1,
default=[default_github_token],
help='GitHub API token')
args = parser.parse_args()
github_token = args.token[0]
result = get_github_endpoint("rate_limit", github_token)
if result == {}:
exit(1)
print("GitHub API Results:")
print(dict_to_pretty_json(result))
print("")
timestamp = result['resources']['core']['reset']
print("Core reset time (local timezone): " + localtime_from_timestamp(timestamp))
print("Core remaining / limit: %d / %d" % (result['resources']['core']['remaining'],
result['resources']['core']['limit']))