mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 09:32:01 +00:00
15 lines
426 B
Python
15 lines
426 B
Python
#!/usr/bin/env python3
|
|
import os
|
|
from github import Github
|
|
|
|
def get_best_robot_token(token_prefix_env_name="ROBOT_TOKEN_", total_tokens=4):
|
|
tokens = {}
|
|
for i in range(total_tokens):
|
|
token_name = token_prefix_env_name + str(i)
|
|
token = os.getenv(token_name)
|
|
gh = Github(token)
|
|
rest, _ = gh.rate_limiting
|
|
tokens[token] = rest
|
|
|
|
return max(tokens.items(), key=lambda x: x[1])[0]
|