diff options
Diffstat (limited to 'gear/client.py')
-rw-r--r-- | gear/client.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/gear/client.py b/gear/client.py index 3cfe51bf..afee49cd 100644 --- a/gear/client.py +++ b/gear/client.py @@ -2,8 +2,11 @@ import gear import sys import json import threading +import requests +import urlparse import distbuild - +#TODO: values from settings +cache_server = 'http://cache.baserock.org:8080' # Artifact build states. These are used to loosely track the state of the # remote cache. @@ -49,7 +52,23 @@ class theController(): print "Setting them as unbuilt done" # TODO: check cache before marking as started: # http://stackoverflow.com/questions/9110593/asynchronous-requests-with-python-requests - self.build_started = True + #self.build_started = True + self._check_cache_state(self.artifact) + + + def _check_cache_state(self, artifact): + print "DEBUG: checking cache..." + artifact_names = [] + def collect_unbuilt_artifacts(artifact): + if artifact.state == UNBUILT: + artifact_names.append(artifact.basename()) + self._map_build_graph(artifact, collect_unbuilt_artifacts) + + url = urlparse.urljoin(cache_server, '/1.0/artifacts') + r = requests.post(url, json=artifact_names) + print r.json() + + def _map_build_graph(self, artifact, callback, components=[]): """Run callback on each artifact in the build graph and return result. |