summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alvarez <pedro.alvarez@codethink.co.uk>2016-03-17 17:21:46 +0000
committerPedro Alvarez <pedro.alvarez@codethink.co.uk>2016-03-27 11:53:02 +0000
commitf58ac21f294da35c60c2f2a5de627c258a7ee15d (patch)
tree11885c78d85d613eb7d2a507ecd463061ae489c4
parent8341281cb8c65d4f9bf4098eefd6f765f317aebc (diff)
downloadmorph-f58ac21f294da35c60c2f2a5de627c258a7ee15d.tar.gz
WIP: start playing with cache
Change-Id: I77b90a9ac40fdc961f0d10285b6f67554a20d490
-rw-r--r--gear/client.py23
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.