flexget.task module#

exception flexget.task.TaskAbort(reason, silent=False)[source]#

Bases: Exception

Parameters:
Return type:

None

class flexget.task.EntryContainer(iterable=None)[source]#

Bases: list

Container 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: object

An iterator over a subset of entries to emulate old task.accepted/rejected/failed/entries properties.

Parameters:
reverse()[source]#
sort(*args, **kwargs)[source]#
class flexget.task.Task(manager, name, config=None, options=None, output=None, session_id=None, priority=None, suppress_warnings=None)[source]#

Bases: object

Represents 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, keyword

  • task.execute.after_plugin

    After a plugin has been executed.

    parameters: task, keyword

  • task.execute.started

    Before a task starts execution

  • task.execute.completed

    After task execution has been completed

    parameters: task

static validate_config(config)[source]#
__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

_execute()[source]#

Execute the task without rerunning.

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)

check_config_hash()[source]#

Check the task’s config hash and update the hash if necessary.

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 phase from execution.

Parameters:

phase (string) – Name of phase

Raises:

ValueErrorphase could not be found.

disable_plugin(plugin)[source]#

Disable plugin from execution.

Parameters:

plugin (string) – Name of plugin

Raises:

ValueErrorplugin could not be found.

execute()[source]#

Execute the task.

If enabled is False task is not executed. Certain options affect how execution is handled.

  • options.disable_phases is a list of phases that are not enabled for this execution.

  • options.inject is a list of Entry instances used instead of running input phase.

find_entry(category='entries', **values)[source]#

Find and return Entry with 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

lock_reruns()[source]#

Prevent modification of max_reruns property.

merge_config(new_config)[source]#
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.PluginInfo instances 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_reruns times.

Parameters:
  • plugin (str) – Plugin name

  • reason (str) – Why the rerun is done

unlock_reruns()[source]#

Allow modification of max_reruns property.

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: VersionedBase

Stores 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#
flexget.task.register_config_key()[source]#
flexget.task.use_task_logging(func)[source]#