diff --git a/larigira/audiogen_randomdir.py b/larigira/audiogen_randomdir.py index 11aee95..abf9b17 100644 --- a/larigira/audiogen_randomdir.py +++ b/larigira/audiogen_randomdir.py @@ -47,3 +47,5 @@ def generate(spec): os.close(tmp[0]) shutil.copy(path, tmp[1]) yield 'file://{}'.format(tmp[1]) + +generate.description = 'Picks random files from a specified directory' diff --git a/larigira/audiogen_script.py b/larigira/audiogen_script.py index 63a2eaf..7b5a72e 100644 --- a/larigira/audiogen_script.py +++ b/larigira/audiogen_script.py @@ -70,3 +70,4 @@ def generate(spec): out = [p for p in out.split('\n') if p] logging.debug('Script %s produced %d files' % (spec['name'], len(out))) return out +generate.description = 'Generate audio through an external script. Experts only.' diff --git a/larigira/audiogen_static.py b/larigira/audiogen_static.py index 6691dc1..dd84347 100644 --- a/larigira/audiogen_static.py +++ b/larigira/audiogen_static.py @@ -22,3 +22,4 @@ def generate(spec): os.close(tmp[0]) shutil.copy(path, tmp[1]) yield 'file://{}'.format(tmp[1]) +generate.description = 'Picks always the same specified file' diff --git a/larigira/dbadmin/__init__.py b/larigira/dbadmin/__init__.py index bea2174..1448033 100644 --- a/larigira/dbadmin/__init__.py +++ b/larigira/dbadmin/__init__.py @@ -9,6 +9,8 @@ from flask import current_app, Blueprint, render_template, jsonify, abort, \ request, redirect, url_for from larigira.entrypoints_utils import get_avail_entrypoints +from larigira.audiogen import get_audiogenerator +from larigira.timegen import get_timegenerator from larigira import forms db = Blueprint('db', __name__, url_prefix='/db', template_folder='templates') @@ -34,7 +36,12 @@ def list(): @db.route('/add/time') def addtime(): kinds = get_avail_entrypoints('larigira.timeform_create') - return render_template('add_time.html', kinds=kinds) + + def gen_info(gen): + return dict(description=getattr(gen, 'description', '')) + info = {kind: gen_info(get_timegenerator(kind)) + for kind in kinds} + return render_template('add_time.html', kinds=kinds, info=info) @db.route('/edit/time/', methods=['GET', 'POST']) @@ -67,13 +74,19 @@ def addtime_kind(kind): eid = get_model().add_alarm(data) return redirect(url_for('db.edit_event', alarmid=eid)) - return render_template('add_time_kind.html', form=form, kind=kind, mode='add') + return render_template('add_time_kind.html', + form=form, kind=kind, mode='add') @db.route('/add/audio') def addaudio(): kinds = get_avail_entrypoints('larigira.audioform_create') - return render_template('add_audio.html', kinds=kinds) + + def gen_info(gen): + return dict(description=getattr(gen, 'description', '')) + info = {kind: gen_info(get_audiogenerator(kind)) + for kind in kinds} + return render_template('add_audio.html', kinds=kinds, info=info) @db.route('/add/audio/', methods=['GET', 'POST']) diff --git a/larigira/dbadmin/templates/add_audio.html b/larigira/dbadmin/templates/add_audio.html index 8eb6e67..86cccb2 100644 --- a/larigira/dbadmin/templates/add_audio.html +++ b/larigira/dbadmin/templates/add_audio.html @@ -7,8 +7,10 @@ Available kinds: {% endblock content %} diff --git a/larigira/dbadmin/templates/add_time.html b/larigira/dbadmin/templates/add_time.html index 76968fb..e98edc3 100644 --- a/larigira/dbadmin/templates/add_time.html +++ b/larigira/dbadmin/templates/add_time.html @@ -7,7 +7,9 @@ Available kinds: diff --git a/larigira/timegen_every.py b/larigira/timegen_every.py index 43d6a77..df28d64 100644 --- a/larigira/timegen_every.py +++ b/larigira/timegen_every.py @@ -41,6 +41,7 @@ class SingleAlarm(Alarm): ''' rings a single time ''' + description = 'Only once, at a specified date and time' def __init__(self, obj): self.dt = getdate(obj['timestamp']) @@ -63,6 +64,7 @@ class FrequencyAlarm(Alarm): ''' rings on {t | exists a k integer >= 0 s.t. t = start+k*t, start