The seedbox.process.flow Module

Provides the definition of workflow (steps and transition).

Implements what happens during each step by binding in the provided plugins for each and updating the db cache after each step.

class seedbox.process.flow.BaseFlow(dbapi, torrent)

Bases: xworkflows.base.WorkflowEnabled

Provides the base workflow implementation.

On binding plugin tasks to each step and determining which plugin is capable of operating on the media files of the specified torrent.

Parameters:
  • dbapi (DBApi) – an instance of the database API
  • torrent (Torrent) – an instance of a parsed torrent metadata
activate

Executes all the tasks for a torrent at activate phase

cancel

NoOp function, ignores all arguments.

complete

Executes all the tasks for a torrent at complete phase

is_done()

Checks if the current state of workflow is either done or cancelled.

Returns:flag indicating workflow is done
Return type:boolean
next_tasks()

Find the list of tasks and associated media eligible for processing.

Returns:list of tasks
Return type:generator
phase

The name of current step/phase of the workflow

Returns:name of current phase
Return type:string
prepare

Executes all the tasks for a torrent at prepare phase

state

Property-like attribute holding the state of a WorkflowEnabled object.

The state is stored in the internal __dict__ of the instance.

tasks

Property for accessing the tasks

Using the context of the current workflow step by looking up the configured plugins.

Returns:list of tasks (BaseTask)
Return type:list
update_state(*args, **kwargs)

Handles the capturing the current state of processing

Parameters:
  • args – required parameter based on decorator (unused)
  • kwargs – required parameter based on decorator (unused)
validate()

Validate that the transition should proceed or not

class seedbox.process.flow.Taskflow

Bases: xworkflows.base.Workflow

Define the workflow conditions for managing torrents;

initial_state = <State: 'init'>
states = StateList({'ready': <State: 'ready'>, 'active': <State: 'active'>, 'init': <State: 'init'>, 'done': <State: 'done'>, 'cancelled': <State: 'cancelled'>})
transitions = TransitionList([Transition('cancel', [<State: 'ready'>, <State: 'active'>], <State: 'cancelled'>), Transition('activate', [<State: 'ready'>], <State: 'active'>), Transition('complete', [<State: 'active'>], <State: 'done'>), Transition('prepare', [<State: 'init'>], <State: 'ready'>)])
seedbox.process.flow.get_tasks(phase)

Gets a list of tasks based the current phase of processing

Parameters:phase – the name of the current phase/step of workflow