diff options
author | Paul Sherwood <paul.sherwood@codethink.co.uk> | 2016-02-07 21:24:15 +0000 |
---|---|---|
committer | Paul Sherwood <paul.sherwood@codethink.co.uk> | 2016-02-07 21:24:15 +0000 |
commit | 791a04dfd578c1c1e584dcbc54eac34072183008 (patch) | |
tree | 3fc621c1ba6944b6242e9944cda45164ea755a2b /kbas | |
parent | 2f7cab47f0140c25d32c4403c040832eb79bdd2c (diff) | |
download | ybd-791a04dfd578c1c1e584dcbc54eac34072183008.tar.gz |
Add ability to check reproducibility
Diffstat (limited to 'kbas')
-rwxr-xr-x | kbas/__main__.py | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/kbas/__main__.py b/kbas/__main__.py index c49c74b..7a411ea 100755 --- a/kbas/__main__.py +++ b/kbas/__main__.py @@ -26,7 +26,7 @@ import yaml from bottle import Bottle, request, response, template, static_file from subprocess import call -from ybd import app +from ybd import app, cache bottle = Bottle() @@ -66,26 +66,11 @@ class KeyedBinaryArtifactServer(object): @bottle.get('/<name>') @bottle.get('/artifacts/<name>') def list(name=""): - - def check(artifact): - try: - artifact = os.path.join(app.config['artifact-dir'], artifact, - artifact) - checkfile = artifact + '.md5' - if not os.path.exists(checkfile): - checksum = app.md5(artifact) - with open(checkfile, "w") as f: - f.write(checksum) - - return(open(checkfile).read()) - except: - return('================================') - current_dir = os.getcwd() os.chdir(app.config['artifact-dir']) names = glob.glob('*' + name + '*') content = [[strftime('%y-%m-%d', gmtime(os.path.getctime(x))), - check(x), x] for x in names] + cache.check(x), x] for x in names] os.chdir(current_dir) return template('kbas', title='Available Artifacts:', @@ -132,6 +117,9 @@ class KeyedBinaryArtifactServer(object): return cache_id = request.forms.get('filename') if os.path.isdir(os.path.join(app.config['artifact-dir'], cache_id)): + if cache.check(cache_id) == request.forms.get('checksum', 'XYZ'): + response.status = 777 # this is the same binary we have + return response.status = 405 # method not allowed, this artifact exists return @@ -149,7 +137,7 @@ class KeyedBinaryArtifactServer(object): shutil.rmtree(unpackdir) os.rename(tmpdir, os.path.join(app.config['artifact-dir'], cache_id)) - checksum = app.md5(artifact) + checksum = cache.md5(artifact) with open(artifact + '.md5', "a") as f: write(f, checksum) response.status = 201 # success! |