-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathreportUsers.py
72 lines (58 loc) · 1.9 KB
/
reportUsers.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
71
72
import urllib2
import json
import subprocess
from subprocess import call
import sys
import os
#course = sys.argv[1]
#assignment = sys.argv[2]
#index = course + '-' + assignment + '-'
#print index
home = os.environ['HOME']
file = open(home + "\\LMS640\\github.tok","r")
token = file.read()
file.close()
repo = "LMS640"
userUrl = 'https://api.github.com/repos/StevensDeptECE/LMS640/collaborators'
req = urllib2.Request(userUrl)
req.add_header('Authorization', 'token %s' % token)
res = urllib2.urlopen(req)
users = json.load(res)
userid = []
for user in users:
userid.append(user['login'])
i = 0
f = open("8th Week.txt",'w')
sys.stdout = f
Users = ["mperrelli", "xinyuliu679", "ghostqu", "kanbd", "mattmelachrinos", "dillonguarino", "VCneverdie", "stRAWRberry", "cbean03", "lzhu1992", "Daniel0729", "xiyukuangdaoke", "CyanideTD", "FUJICJK", "ybai8", "soberkiller", "Yliuinstevens","yzhan90top", "bhavitha590", "YuYu12", "sihanwang94", "zbinger", "hxiao3", "chunyiguo", "dippanpatel"]
print "Date: 8th Week"
for User in Users:
#print i
author = "--author=" + Users[i]
with open('test.log', "w") as outfile:
subprocess.call(["git","log",author, "-p",'--since="3/11/2017"','--until="3/17/2017"'], stdout=outfile)
#call(["git", "log", "-p", ">test.log"])
countCommit = 0
countLine = 0
file = open("test.log","r")
gitlog = file.read()
file.close()
gitlines = gitlog.splitlines()
#print gitlines
for line in gitlines:
#print line
if "commit" in line:
countCommit = countCommit + 1
#if "Author" in line:
#print line
#if "Date" in line:
#print line
if line.startswith('+') or ('-'):
countLine = countLine + 1
print "Author: %s"%Users[i]
print "Commit: %d"%countCommit
print "Lines: %d" %countLine
i = i + 1
f.close()
#with open("output.txt", "w") as output:
# subprocess.call(["python", "reportUsers.py"], stdout=output)