forked from cryptodotis/code-peer-review
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cronjob.py
executable file
·51 lines (40 loc) · 1.52 KB
/
cronjob.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
#!/usr/bin/python
import MySQLdb, argparse, time
from common import *
from config import Config
from database import DB
from repo import Repo
from commit import Commit
import svnpuller, gitpuller
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Given a startdate and enddate, process the commits between for all repos in the database.')
parser.add_argument('startdate')
parser.add_argument('enddate')
args = parser.parse_args()
args.startdate, args.enddate = fixDates(args.startdate, args.enddate)
print "Searching between", time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime(args.startdate)), "-", time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime(args.enddate))
conn = DB.getConn()
c = conn.cursor()
c.execute("SELECT * FROM " + DB.repo._table)
rows = c.fetchall()
for i in rows:
r = Repo()
r.loadFromDatabase(i)
r.pprint()
module = -1
if r.type == Repo.Type.SVN:
module = svnpuller
elif r.type == Repo.Type.GIT:
module = gitpuller
if module != -1:
try:
commits = module.getCommits(r, args.startdate, args.enddate)
except:
print "Error pulling commits for", r.url
commits = []
for c in commits:
print ".",
c.save()
if commits: print ""
else:
print "Do not have a module for", r.url