forked from stewartpark/DevTrain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
32 lines (29 loc) · 789 Bytes
/
app.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
from git import Repo
import json
import control
import time
repos = json.load(open("./repos.json"))
while True:
run_train = False
for i, repo in enumerate(repos):
path = repo['path']
print path
last_commit = repo['last_commit']
branch = repo['branch']
r = Repo(path)
try:
r.remotes.origin.pull()
lc = r.commit(branch).hexsha
if lc != last_commit:
run_train = True
repos[i]['last_commit'] = lc
except:
print 'Oops.'
if run_train:
print 'Chu chu~~~'
control.go(control.FORWARD_SLOW)
time.sleep(30)
control.stop()
print 'Stopped.'
time.sleep(5)
json.dump(repos, open("./repos.json", "w"))