Previous topic

synfu.fucore.FUCore – Common utility and helper methods

Next topic

Appendix A: Synfu example config

This Page

synfu.imp.Imp – Periodic Imp - background tasks

New in version 0.4.10.

Platforms: Unix, MacOS, Windows

Module author: René Köcher <shirk@bitspin.org>

class synfu.imp.Imp

Imp - the periodic Imp

SynFU Imp is a background helper designed to run periodic maintenance jobs.
At the time of this writing the following jobs are built-in:
Each job is provided as a separate python file containing arbitrary
job definitions in the form of synfu.imp.ImpJob subclasses.
class synfu.imp.ImpJob

An abstract job.

ImpJob provides the base for custom SynFU oriented jobs.
Any derived subclass will be registered as a new job upon import.
_log(message, *args, **kwargs)
Log a message using syslog as well as sys.stdout.
Messages will be prefixed using the current __class__.__name__.
Parameters:
  • message – The pre-formatted log-message.
  • rec – Optional recursion level used to indent messages.
  • verbosity – Minimal verbosity required to display this message.
Returns:

None

job_config(name, defaults={})

Load job specific config object.

This method will try to load a subsection of the Imp-configuration.
The optional dictionary defaults contains a list of default key,value pairs.
Param :name: The name of the config subsection beneath Imp.jobs
Param :defaults: A dict with key,value pairs for default parameters
Returns:A JobConf instance with all top-level settings converted to attributes.
show_help(*args)

Print the available command line options for this job.

Params :*args: the list of command line arguments (suitable for use by optparse)
Returns:None

Note

You should really overwrite this one ;)

needs_run(*args)

Check run status.

This method will be called by Imp to check if this job needs to be run.
The final decision is up to the job and determined by the return code.
Params :*args: the list of command line arguments (suitable for use by optparse)
Returns:True if the job needs to be run
run()

Execute the job

This method will be called on a successful call to needs_run().
On success the job should return True, False otherwise.
Returns:True on success
Returns:False on failure

Note

Imp will wrap job execution in a catch-all try-block. However it is considered good practice to care for possible exceptions.