flexget.task module#
- class flexget.task.EntryContainer(iterable=None)[source]#
Bases:
listContainer for a list of entries, also contains accepted, rejected failed iterators over them.
- Parameters:
iterable (list | None)
- property accepted#
- property entries#
- property failed#
- property rejected#
- property undecided#
- class flexget.task.EntryIterator(entries, states)[source]#
Bases:
objectAn iterator over a subset of entries to emulate old task.accepted/rejected/failed/entries properties.
- Parameters:
states (EntryState | Iterable[EntryState])
- class flexget.task.Task(manager, name, config=None, options=None, output=None, session_id=None, priority=None, suppress_warnings=None)[source]#
Bases:
objectRepresents one task in the configuration.
Fires events:
task.execute.before_plugin
Before a plugin is about to be executed. Note that since this will also include all builtin plugins the amount of calls can be quite high
parameters: task, keywordtask.execute.after_plugin
After a plugin has been executed.
parameters: task, keywordtask.execute.started
Before a task starts execution
task.execute.completed
After task execution has been completed
parameters: task
- __run_plugin(plugin, phase, args=None, kwargs=None)#
Execute given plugins phase method, with supplied args and kwargs.
If plugin throws unexpected exceptions
abort()will be called.- Parameters:
plugin (PluginInfo) – Plugin to be executed
phase (string) – Name of the phase to be executed
args – Passed to the plugin
kwargs – Passed to the plugin
- __run_task_phase(phase)#
Execute task phase, ie. call all enabled plugins on the task.
Fires events:
task.execute.before_plugin
task.execute.after_plugin
- Parameters:
phase (string) – Name of the phase
- abort(reason='Unknown', silent=False, traceback=None)[source]#
Abort this task execution, no more plugins will be executed except the abort handling ones.
- Parameters:
traceback (str | None)
- config_changed()[source]#
Set config_modified flag to True for the remainder of this run.
Used when the db changes, and all entries need to be reprocessed.
- copy()#
- disable_phase(phase)[source]#
Disable
phasefrom execution.- Parameters:
phase (string) – Name of
phase- Raises:
ValueError – phase could not be found.
- disable_plugin(plugin)[source]#
Disable
pluginfrom execution.- Parameters:
plugin (string) – Name of
plugin- Raises:
ValueError – plugin could not be found.
- execute()[source]#
Execute the task.
If
enabledis False task is not executed. Certainoptionsaffect how execution is handled.options.disable_phasesis a list of phases that are not enabled for this execution.options.injectis a list ofEntryinstances used instead of running input phase.
- find_entry(category='entries', **values)[source]#
Find and return
Entrywith given attributes from task or None.- Parameters:
category (string) – entries, accepted, rejected or failed. Defaults to entries.
values – Key values of entries to be searched
- Returns:
Entry or None
- plugins(phase=None)[source]#
Get currently enabled plugins.
- Parameters:
phase (string) – Optional, limits to plugins currently configured on given phase, sorted in phase order.
- Returns:
An iterator over configured
flexget.plugin.PluginInfoinstances enabled on this task.
- render(template)[source]#
Render a template string based on fields in the entry.
- Parameters:
template – A template string or FlexGetTemplate that uses jinja2 or python string replacement format.
- Returns:
The result of the rendering.
- Return type:
string
- Raises:
RenderError – If there is a problem.
- rerun(plugin=None, reason=None)[source]#
Immediately re-run the task after execute has completed, task can be re-run up to
max_rerunstimes.
- RERUN_DEFAULT = 5#
- RERUN_MAX = 100#
- _counter = count(0)#
- property accepted#
Deprecated since version Use: API v3.
- property all_entries#
Deprecated since version Use: API v3.
- property entries#
Deprecated since version Use: API v3.
- property failed#
Deprecated since version Use: API v3.
- property is_rerun#
- property max_reruns#
How many times task can be rerunned before stopping.
- property rejected#
Deprecated since version Use: API v3.
- property rerun_count#
- property reruns_locked#
- property undecided#
Deprecated since version Use: API v3.
Note
We did not migrate to v3
If I remember correctly the idea was to make v3 signature on_task_xxx(task, config, entries)
Param entries would be EntryContainer, which has convenience iterator methods:
entries.accepted
entries.failed
etc, which you see here
- class flexget.task.TaskConfigHash(**kwargs)[source]#
Bases:
VersionedBaseStores the config hash for tasks so that we can tell if the config has changed since last run.
- _sa_class_manager = {'hash': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'task': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}#
- hash#
- id#
- task#