-
Notifications
You must be signed in to change notification settings - Fork 1
/
orgs_checker.py
72 lines (53 loc) · 1.77 KB
/
orgs_checker.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/local/bin/python2.7
from github import Github
import argparse
import os
def repo_count(repo_list):
count = 0
for repo in repo_list:
count += 1
return count
def repo_update(repo_list, path):
for repo in repo_list:
print repo.name
print path + repo.name.strip()
def get_user(account):
info_file = open(account)
user = info_file.readlines()
info_file.close()
return user
def get_organizations(organizations):
info_file = open(organizations)
orgs = info_file.readlines()
info_file.close()
return orgs
def org_checker(account, organizations):
user_info = get_user(account)
user = user_info[0].strip()
pw = user_info[1].strip()
bp = user_info[2].strip()
g = Github(user, pw)
orgs_list = get_organizations(organizations)
#I need it for organizations not users...
#for orgs.strip() in orgs_list
for org in orgs_list:
repo_list = g.get_organization(org.strip()).get_repos();
print "%s has %d repos" % (org.strip(), repo_count(repo_list))
path = bp + org + "/"
repo_update(repo_list, path)
print ""
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="prints all repos")
parser.add_argument("account", help="path to file with github username and password")
parser.add_argument("organizations", help="path to file with list of organizations")
args = parser.parse_args()
if not os.path.exists(args.account):
stderr.write("file %s not found." % args.account)
exit()
if not os.path.exists(args.organizations):
stderr.write("file %s not found." % args.organizations)
exit()
if org_checker(args.account, args.organizations):
print "Error"
else:
print "Done"