@@ -49,13 +49,15 @@ def __init__(self, repos, interval, branch, callback):
49
49
self .branch = branch
50
50
self .callback = callback
51
51
self .repos = repos
52
+ for repo in self .repos :
53
+ log .info ("Monitoring remote repo for: {0}" .format (repo ))
52
54
scheduler .enter (interval , 1 , self .update_from_git , ())
53
55
54
56
def update_from_git (self ):
55
57
check_call (['git' , 'fetch' ])
56
58
current_path = os .getcwd ()
57
- for repo in repos :
58
- os .chdir (self . path )
59
+ for repo in self . repos :
60
+ os .chdir (repo )
59
61
current_ref = Popen (['git' , 'symbolic-ref' , 'HEAD' ], stdout = PIPE ).communicate ()[0 ].strip ()
60
62
if current_ref != 'refs/heads/{0}' .format (self .branch ):
61
63
log .info ('Repository is currently on: {0}. Switching to: refs/heads/{1}' .format (current_ref , self .branch ))
@@ -67,7 +69,7 @@ def update_from_git(self):
67
69
remote_hash = p2 .communicate ()[0 ].strip ()
68
70
log .debug ('Repo: {0}. Local hash: {1}. Remote hash: {2}' .format (repo , local_hash , remote_hash ))
69
71
if local_hash != remote_hash :
70
- log .info ('Updating local repository: {0} to: {1}' .format (repo , remote_hash ))
72
+ log .info ('Updating local repository: {0} to: {1}' .format (repo , remote_hash ))
71
73
check_call (['git' , 'pull' , 'origin' , self .branch ])
72
74
if self .callback is not None :
73
75
log .info ('Calling callback for {0}' .format (repo ))
@@ -81,6 +83,15 @@ def update_from_git(self):
81
83
def start (self ):
82
84
scheduler .run ()
83
85
86
+ def stop (self ):
87
+ if not scheduler .empty :
88
+ for event in scheduler .queue :
89
+ try :
90
+ scheduler .cancel (event )
91
+ except ValueError :
92
+ log .debug ('Job beat us to the shutdown punch: {0}' .format (event ))
93
+
94
+
84
95
def kill_handler (signal , frame ):
85
96
log .info ('Shutting Down' )
86
97
if not scheduler .empty :
0 commit comments