summaryrefslogtreecommitdiff
path: root/kbas
diff options
context:
space:
mode:
authorPaul Sherwood <paul.sherwood@codethink.co.uk>2016-02-08 22:10:00 +0000
committerPaul Sherwood <paul.sherwood@codethink.co.uk>2016-02-08 22:10:27 +0000
commitb110c853f52ac4f953357c1c338d1d0336e1198b (patch)
tree479fe37e27560f44d02bc21dd9bf9c0f4237bfd3 /kbas
parentfeaf848731dc47389a012d6e66f13f1d27ce0b67 (diff)
downloadybd-b110c853f52ac4f953357c1c338d1d0336e1198b.tar.gz
Fix a couple of Server Error 500
Diffstat (limited to 'kbas')
-rwxr-xr-xkbas/__main__.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/kbas/__main__.py b/kbas/__main__.py
index 7a411ea..2674cac 100755
--- a/kbas/__main__.py
+++ b/kbas/__main__.py
@@ -69,8 +69,12 @@ class KeyedBinaryArtifactServer(object):
current_dir = os.getcwd()
os.chdir(app.config['artifact-dir'])
names = glob.glob('*' + name + '*')
- content = [[strftime('%y-%m-%d', gmtime(os.path.getctime(x))),
- cache.check(x), x] for x in names]
+ try:
+ content = [[strftime('%y-%m-%d', gmtime(os.path.getctime(x))),
+ cache.check(x), x] for x in names]
+ except:
+ content = [['--------', cache.check(x), x] for x in names]
+
os.chdir(current_dir)
return template('kbas',
title='Available Artifacts:',
@@ -125,7 +129,7 @@ class KeyedBinaryArtifactServer(object):
tempfile.tempdir = app.config['artifact-dir']
tmpdir = tempfile.mkdtemp()
- try:
+ if True:
upload = request.files.get('file')
artifact = os.path.join(tmpdir, cache_id)
upload.save(artifact)
@@ -135,16 +139,19 @@ class KeyedBinaryArtifactServer(object):
app.log(this, 'ERROR: Problem unpacking', artifact)
raise
shutil.rmtree(unpackdir)
- os.rename(tmpdir, os.path.join(app.config['artifact-dir'],
- cache_id))
checksum = cache.md5(artifact)
with open(artifact + '.md5', "a") as f:
- write(f, checksum)
+ f.write(checksum)
+ os.rename(tmpdir, os.path.join(app.config['artifact-dir'],
+ cache_id))
response.status = 201 # success!
return
except:
# something went wrong, clean up
- shutil.rmtree(tmpdir)
+ try:
+ shutil.rmtree(tmpdir)
+ except:
+ pass
response.status = 999
return