-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathexample.py
More file actions
executable file
·24 lines (22 loc) · 874 Bytes
/
example.py
File metadata and controls
executable file
·24 lines (22 loc) · 874 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import argparse
import lib
from datetime import datetime
from time import sleep
from yaml import load, SafeLoader
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(
"--sleep", type=int, default=60 * 5, help="Number of seconds between requests"
)
args = parser.parse_args()
with open('.config.yml') as config_file:
config = load(config_file, Loader=SafeLoader)
for meta in config.get('orgs', list()):
ghapi = lib.GitHubAPI(meta)
print('EXAMPLE AUTOMATED TOKEN REFRESH USING GITHUB APP AND PYGITHUB')
print('ctrl-c to exit; otherwise runs infinitely\n')
while True:
print(f"- TIMESTAMP: {datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')}")
print(f"- REPO OBJECT: {ghapi.org_repos()[0].full_name}\n")
sleep(args.sleep)
print('done')