Skip to content
commandline edited this page Sep 13, 2010 · 31 revisions

As of version 0.20, all of the parts of the commit message flashbake generates come from plugins.
As of version 0.22, the names of the stock plugins changed. This reflects the shift to implementing them as classes rather than modules.

There are four stock plugins:

flashbake.plugins.timezone:TimeZone
flashbake.plugins.weather:Weather
flashbake.plugins.uptime:UpTime
flashbake.plugins.feed:Feed

These are enabled by adding the a “plugins:” line or lines to your .flashbake file.

plugins:flashbake.plugins.timezone:TimeZone,flashbake.plugins.weather:Weather
plugins:flashbake.plugins.feed:Feed

flashbake will combine multiple “plugins:” lines to create the total list of plugins to use.

Implementing Plugins

Plugins should extend the class flashbake.plugins.AbstractMessagePlugin. If a plugin uses the network, it should implementing an init that takes a plugin_spec string and call the super init passing in that string along with a True argument to indicate the plugin is connectable. See Feed and Weather for examples.

A plugin may implement an init method that takes a ControlConfig argument. In the init(self, config) method, the plugin may call the parent’s requireproperty and optionalproperty methods. These methods take a name argument, the name of an option in the control file that should be set as a property on the plugin itself. optionalproperty also takes an optional argument, a type, to which the option value string will be coerced. See Feed for examples of both of these methods being used.

There is also a shareproperty method from the flashbake.ControlConfig class that sets the option as a property on the config instance and on the plugin. See Weather for an example.

flashbake.plugins.timezone:TimeZone

This plugin just adds the configured time zone on your computer to the commit message. It tries a few things to determine the timezone.

  1. First it looks for an environment variable, TZ, which many Linux distros set.
  2. If that is not set, it will look for a file, “/etc/timezone”, and try to read it. Other Linux distros will create and write this file.
  3. If that fails, it will look for a symbolic link, “/etc/localtime”, and parse the name of the file to which it points. This is common on Macs.
  4. It will look for a line, “timezone:” in the project’s flashbake file and use that if present.

If all of these fail, then it will write a line to that effect in the commit message.

flashbake.plugins.weather

This plugin uses the same logic as the timezone plugin to get a timezone value. It then parses that as the most common timezone names follow the form of “Continent/City_name”. It will parse out the city and fix it to drop out the underscore, if there is one. It then calls an undocumented Google API to get weather data as an XML file which it parses to construct a nice, readable line for the commit message.

flashbake.plugins.uptime

This plugin read the file, “/proc/uptime”, and parses its contents to generate a human readable amount of time that your computer has been up and running. This plugin will only work on Linux.

flashbake.plugins.feed

This plugin requires some addition lines in your .flashbake configuration file.

  • feed: – where is the URL to an RSS feed that you want the plugin to read. It can be any RSS feed, but most likely you’ll want to use the one for your blog. As of 0.20, the feed must be RSS, Atom feeds won’t work. I am planning on fixing this in a future version.
  • author:<author’s name> – where <author’s name> is the name of the author in the feed, exactly as it appears in the feed. The plugin will only output feed items that match this author value.
  • limit: – where is the maximum number of items to pull from the feed.

As of 0.20, if you use the feed plugin, all three configuration lines must be specified. In a future version of flashbake, I will make the author line optional and maybe the limit, with some documented default for the maximum items to pull.

Clone this wiki locally