larigira package¶
Submodules¶
larigira.audioform_http module¶
-
class
larigira.audioform_http.
AudioForm
(*args, **kwargs)[source]¶ Bases:
flask_wtf.form.Form
-
nick
= <UnboundField(StringField, ('Audio nick',), {'validators': [<wtforms.validators.Required object>], 'description': 'A simple name to recognize this audio'})>¶
-
submit
= <UnboundField(SubmitField, ('Submit',), {})>¶
-
urls
= <UnboundField(StringField, ('URLs',), {'validators': [<wtforms.validators.Required object>], 'description': 'URL of the file to download'})>¶
-
larigira.audioform_mostrecent module¶
-
class
larigira.audioform_mostrecent.
AudioForm
(*args, **kwargs)[source]¶ Bases:
flask_wtf.form.Form
-
maxage
= <UnboundField(StringField, ('Max age',), {'validators': [<wtforms.validators.Required object>], 'description': 'in seconds, or human-readable (like 9w3d12h)'})>¶
-
nick
= <UnboundField(StringField, ('Audio nick',), {'validators': [<wtforms.validators.Required object>], 'description': 'A simple name to recognize this audio'})>¶
-
path
= <UnboundField(AutocompleteStringField, ('dl-suggested-dirs', 'Path'), {'validators': [<wtforms.validators.Required object>], 'description': 'Directory to pick file from'})>¶
-
submit
= <UnboundField(SubmitField, ('Submit',), {})>¶
-
larigira.audioform_podcast module¶
-
class
larigira.audioform_podcast.
AudioForm
(*args, **kwargs)[source]¶ Bases:
flask_wtf.form.Form
-
max_len
= <UnboundField(StringField, ('Accetta solo audio lunghi al massimo:',), {'description': 'Leaving this empty will disable this filter'})>¶
-
min_len
= <UnboundField(StringField, ('Accetta solo audio lunghi almeno:',), {'description': 'Leaving this empty will disable this filter'})>¶
-
nick
= <UnboundField(StringField, ('Audio nick',), {'validators': [<wtforms.validators.Required object>], 'description': 'A simple name to recognize this audio'})>¶
-
reverse
= <UnboundField(BooleanField, ('Reverse sort (descending)',), {})>¶
-
sort_by
= <UnboundField(SelectField, ('Sort episodes',), {'choices': [('none', "Don't sort"), ('random', 'Random'), ('duration', 'Duration'), ('date', 'date')]})>¶
-
start
= <UnboundField(IntegerField, ('Play from episode number',), {'description': 'Episodes count from 0; 0 is a sane default'})>¶
-
submit
= <UnboundField(SubmitField, ('Submit',), {})>¶
-
url
= <UnboundField(URLField, ('URL',), {'validators': [<wtforms.validators.Required object>], 'description': 'URL of the podcast; it must be valid xml'})>¶
-
larigira.audioform_randomdir module¶
-
class
larigira.audioform_randomdir.
Form
(*args, **kwargs)[source]¶ Bases:
flask_wtf.form.Form
-
howmany
= <UnboundField(IntegerField, ('Number',), {'validators': [<wtforms.validators.Optional object>], 'default': 1, 'description': 'How many songs to be pickedfrom this dir; defaults to 1'})>¶
-
nick
= <UnboundField(StringField, ('Audio nick',), {'validators': [<wtforms.validators.Required object>], 'description': 'A simple name to recognize this audio'})>¶
-
path
= <UnboundField(AutocompleteStringField, ('dl-suggested-dirs', 'Path'), {'validators': [<wtforms.validators.Required object>], 'description': 'Full path to source directory'})>¶
-
submit
= <UnboundField(SubmitField, ('Submit',), {})>¶
-
larigira.audioform_script module¶
-
class
larigira.audioform_script.
ScriptAudioForm
(*args, **kwargs)[source]¶ Bases:
flask_wtf.form.Form
-
args
= <UnboundField(StringField, ('Arguments',), {'description': 'arguments, separated by ";"'})>¶
-
name
= <UnboundField(AutocompleteStringField, ('dl-suggested-scripts', 'Name'), {'validators': [<wtforms.validators.Required object>], 'description': 'filename (NOT path) of the script'})>¶
-
nick
= <UnboundField(StringField, ('Audio nick',), {'validators': [<wtforms.validators.Required object>], 'description': 'A simple name to recognize this audio'})>¶
-
submit
= <UnboundField(SubmitField, ('Submit',), {})>¶
-
larigira.audioform_static module¶
-
class
larigira.audioform_static.
StaticAudioForm
(*args, **kwargs)[source]¶ Bases:
flask_wtf.form.Form
-
nick
= <UnboundField(StringField, ('Audio nick',), {'validators': [<wtforms.validators.Required object>], 'description': 'A simple name to recognize this audio'})>¶
-
path
= <UnboundField(AutocompleteStringField, ('dl-suggested-files', 'Path'), {'validators': [<wtforms.validators.Required object>], 'description': 'Full path to audio file'})>¶
-
submit
= <UnboundField(SubmitField, ('Submit',), {})>¶
-
larigira.audiogen module¶
larigira.audiogen_http module¶
larigira.audiogen_mostrecent module¶
larigira.audiogen_mpdrandom module¶
larigira.audiogen_podcast module¶
larigira.audiogen_randomdir module¶
larigira.audiogen_script module¶
script audiogenerator: uses an external program to generate audio URIs
a script can be any valid executable in $XDG_CONFIG_DIR/larigira/scripts/<name>; for security reasons, it must be executable and owned by the current user. The audiospec can specify arguments to the script, while the environment cannot be customized (again, this is for security reasons).
The script should assume a minimal environment, and being run from /. It must output one URI per line; please remember that URI must be understood from mpd, so file paths are not valid; file:///file/path.ogg is a valid URI instead. The output MUST be UTF-8-encoded. Empty lines will be skipped. stderr will be logged, so please be careful. any non-zero exit code will result in no files being added.and an exception being logged.
larigira.audiogen_static module¶
larigira.config module¶
Taken from flask-appconfig
-
larigira.config.
from_envvars
(prefix=None, envvars=None, as_json=True)[source]¶ Load environment variables in a dictionary
Values are parsed as JSON. If parsing fails with a ValueError, values are instead used as verbatim strings.
Parameters: - prefix – If
None
is passed as envvars, all variables fromenviron
starting with this prefix are imported. The prefix is stripped upon import. - envvars – A dictionary of mappings of environment-variable-names
to Flask configuration names. If a list is passed
instead, names are mapped 1:1. If
None
, see prefix argument. - as_json – If False, values will not be parsed as JSON first.
- prefix – If
larigira.entrypoints_utils module¶
larigira.event module¶
-
class
larigira.event.
Monitor
(parent_queue, conf)[source]¶ Bases:
larigira.eventutils.ParentedLet
Manages timegenerators and audiogenerators for DB events
The mechanism is partially based on ticks, partially on scheduled actions. Ticks are emitted periodically; at every tick,
on_tick
checks if any event is “near enough”. If an event is near enough, it is “scheduled
”: a greenlet is run which will wait for the right time, then generate the audio, then submit to Controller.The tick mechanism allows for events to be changed on disk: if everything was scheduled immediately, no further changes would be possible. The scheduling mechanism allows for more precision, catching exactly the right time. Being accurate only with ticks would have required very frequent ticks, which is cpu-intensive.
larigira.event_manage module¶
larigira.eventutils module¶
-
class
larigira.eventutils.
ParentedLet
(queue)[source]¶ Bases:
gevent._greenlet.Greenlet
ParentedLet is just a helper subclass that will help you when your greenlet main duty is to “signal” things to a parent_queue.
It won’t save you much code, but “standardize” messages and make explicit the role of that greenlet
larigira.forms module¶
larigira.formutils module¶
-
class
larigira.formutils.
AutocompleteStringField
(datalist, *args, **kwargs)[source]¶ Bases:
wtforms.fields.core.StringField
-
class
larigira.formutils.
AutocompleteTextInput
(datalist=None)[source]¶ Bases:
wtforms.widgets.core.Input
-
class
larigira.formutils.
DateTimeInput
(input_type=None)[source]¶ Bases:
wtforms.widgets.core.Input
-
input_type
= 'datetime-local'¶
-
-
class
larigira.formutils.
EasyDateTimeField
(label=None, validators=None, **kwargs)[source]¶ Bases:
wtforms.fields.core.Field
a “fork” of DateTimeField which uses HTML5 datetime-local
The format is not customizable, because it is imposed by the HTML5 specification.
This field does not ensure that browser actually supports datetime-local input type, nor does it provide polyfills.
-
formats
= ('%Y-%m-%dT%H:%M:%S', '%Y-%m-%dT%H:%M')¶
-
process_formdata
(valuelist)[source]¶ Process data received over the wire from a form.
This will be called during form construction with data supplied through the formdata argument.
Parameters: valuelist – A list of strings to process.
-
widget
= <larigira.formutils.DateTimeInput object>¶
-
larigira.fsutils module¶
larigira.main module¶
This module is for the main application logic
larigira.mpc module¶
-
class
larigira.mpc.
MPDWatcher
(queue, conf, client=None)[source]¶ Bases:
larigira.eventutils.ParentedLet
MPDWatcher notifies parent about any mpd event
-
class
larigira.mpc.
Player
(conf)[source]¶ Bases:
object
The player contains different mpd-related methods
check_playlist determines whether the playlist is long enough and run audiogenerator accordingly
enqueue receive audios that have been generated by Monitor and (if filters allow it) enqueue it to MPD playlist
-
continous_audiospec
¶
-
larigira.test_unused module¶
larigira.timeform_base module¶
-
class
larigira.timeform_base.
FrequencyAlarmForm
(*args, **kwargs)[source]¶ Bases:
flask_wtf.form.Form
-
end
= <UnboundField(EasyDateTimeField, ('End date and time',), {'validators': [<wtforms.validators.Optional object>], 'description': 'After this, no alarm will ring. Expressed as YYYY-MM-DDTHH:MM:SS. If omitted, the alarm will always ring'})>¶
-
interval
= <UnboundField(StringField, ('Frequency',), {'validators': [<wtforms.validators.Required object>], 'description': 'in seconds, or human-readable (like 9w3d12h)'})>¶
-
nick
= <UnboundField(StringField, ('Alarm nick',), {'validators': [<wtforms.validators.Required object>], 'description': 'A simple name to recognize this alarm'})>¶
-
start
= <UnboundField(EasyDateTimeField, ('Start date and time',), {'validators': [<wtforms.validators.Optional object>], 'description': 'Before this, no alarm will ring. Expressed as YYYY-MM-DDTHH:MM:SS. If omitted, the alarm will always ring'})>¶
-
submit
= <UnboundField(SubmitField, ('Submit',), {})>¶
-
weekdays
= <UnboundField(SelectMultipleField, ('Days on which the alarm should be played',), {'choices': [('1', 'Monday'), ('2', 'Tuesday'), ('3', 'Wednesday'), ('4', 'Thursday'), ('5', 'Friday'), ('6', 'Saturday'), ('7', 'Sunday')], 'default': ['1', '2', '3', '4', '5', '6', '7'], 'validators': [<wtforms.validators.Required object>], 'description': 'The alarm will ring only on selected weekdays'})>¶
-
-
class
larigira.timeform_base.
SingleAlarmForm
(*args, **kwargs)[source]¶ Bases:
flask_wtf.form.Form
-
dt
= <UnboundField(EasyDateTimeField, ('Date and time',), {'validators': [<wtforms.validators.Required object>], 'description': 'Date to ring on, expressed as 2000-12-31T13:42:00'})>¶
-
nick
= <UnboundField(StringField, ('Alarm nick',), {'validators': [<wtforms.validators.Required object>], 'description': 'A simple name to recognize this alarm'})>¶
-
submit
= <UnboundField(SubmitField, ('Submit',), {})>¶
-
larigira.timeform_cron module¶
-
class
larigira.timeform_cron.
CronAlarmForm
(*args, **kwargs)[source]¶ Bases:
flask_wtf.form.Form
-
cron_format
= <UnboundField(StringField, ('cron-like format',), {'validators': [<wtforms.validators.Required object>], 'description': 'the frequency specification, as in the <tt>cron</tt> command; see <a href="https://crontab.guru/">crontab.guru</a> for a hepl with cron format'})>¶
-
exclude
= <UnboundField(TextAreaField, ('cron-like format; any matching time will be excluded',), {'description': 'Another cron-like thing to _exclude_ events'})>¶
-
nick
= <UnboundField(StringField, ('Alarm nick',), {'validators': [<wtforms.validators.Required object>], 'description': 'A simple name to recognize this alarm'})>¶
-
submit
= <UnboundField(SubmitField, ('Submit',), {})>¶
-
larigira.timegen module¶
main module to read and get informations about alarms
larigira.timegen_cron module¶
-
class
larigira.timegen_cron.
CronAlarm
(obj)[source]¶ Bases:
larigira.timegen_every.Alarm
-
description
= 'Frequency specified by cron-like format. nerds preferred'¶
-
larigira.timegen_every module¶
-
class
larigira.timegen_every.
Alarm
[source]¶ Bases:
object
-
class
larigira.timegen_every.
FrequencyAlarm
(obj)[source]¶ Bases:
larigira.timegen_every.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'¶
-
-
class
larigira.timegen_every.
SingleAlarm
(obj)[source]¶ Bases:
larigira.timegen_every.Alarm
rings a single time
-
description
= 'Only once, at a specified date and time'¶
-
larigira.unused module¶
- This component will look for files to be removed. There are some assumptions:
- Only files in $TMPDIR are removed. Please remember that larigira has its own specific TMPDIR
- MPD URIs are parsed, and only file:/// is supported