Skip to content

Commit

Permalink
Show download count
Browse files Browse the repository at this point in the history
  • Loading branch information
devcurmudgeon committed Sep 13, 2016
1 parent e83f8b0 commit db7d285
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kbas/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def __init__(self):
os.path.join(os.path.dirname(__file__), 'config', 'kbas.conf')])
app.config['start-time'] = datetime.now()
app.config['last-upload'] = datetime.now()
app.config['downloads'] = 0

try:
import cherrypy
Expand Down Expand Up @@ -90,6 +91,7 @@ def get_morph_artifact():
@bottle.get('/get/<cache_id>')
def get_artifact(cache_id):
f = os.path.join(cache_id, cache_id)
app.config['downloads'] += 1
return static_file(f, root=app.config['artifact-dir'], download=True,
mimetype='application/x-tar')

Expand All @@ -100,13 +102,15 @@ def status():
free = stat.f_frsize * stat.f_bavail / 1000000000
artifacts = len(os.listdir(app.config['artifact-dir']))
started = app.config['start-time'].strftime('%y-%m-%d %H:%M:%S')
downloads = app.config['downloads']
last_upload = app.config['last-upload'].strftime('%y-%m-%d %H:%M:%S')
content = [['Started:', started, None]]
content += [['Last upload:', last_upload, None]]
if app.config.get('last-reject'):
content += [['Last reject:', app.config['last-reject'], None]]
content += [['Space:', str(free) + 'GB', None]]
content += [['Artifacts:', str(artifacts), None]]
content += [['Downloads:', downloads, None]]
return template('kbas',
title='KBAS status',
content=content,
Expand Down

0 comments on commit db7d285

Please sign in to comment.