parent
556783c2ab
commit
1e902a069d
7 changed files with 29 additions and 6 deletions
|
@ -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'
|
||||
|
|
|
@ -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.'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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/<int:alarmid>', 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/<kind>', methods=['GET', 'POST'])
|
||||
|
|
|
@ -7,8 +7,10 @@
|
|||
Available kinds:
|
||||
<ul>
|
||||
{% for kind in kinds|sort %}
|
||||
<li><a href="{{url_for('db.addaudio_kind', kind=kind)}}">{{kind}}
|
||||
{% endfor %}
|
||||
<li><a href="{{url_for('db.addaudio_kind', kind=kind)}}">{{kind}}</a>
|
||||
- {{info[kind]['description']}}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
Available kinds:
|
||||
<ul>
|
||||
{% for kind in kinds|sort %}
|
||||
<li><a href="{{url_for('db.addtime_kind', kind=kind)}}">{{kind}}
|
||||
<li><a href="{{url_for('db.addtime_kind', kind=kind)}}">{{kind}}</a>
|
||||
- {{info[kind]['description']}}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -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<t<end}
|
||||
'''
|
||||
description = 'Events at a specified frequency. Example: every 30minutes'
|
||||
|
||||
def __init__(self, obj):
|
||||
self.start = getdate(obj['start'])
|
||||
|
|
Loading…
Reference in a new issue