Bitten Recipe Extractor


These are two scripts that retrieve a Trac's Bitten rule sets. These scripts allow you to make off-line changes easily with your favorite text editor. Once the changes have been made, a second script uploads these changes to the server.

Reading and Writing Recipes

Each Bitten rule will be a separate <recipe_name>.recipe file.

Each Python script uses the same single argument, namely the path to your Trac environment:

$ trac-admin /some/trac/environment

To be absolutely clear on this, and to add additional text spam to this site:

$ sudo python /some/trac/environment


$ sudo python /some/trac/environment


When you perform a, a directory will be created with a name equal to your Trac directory with '_recipes' appended to it (trac-directory-name_recipes). The recipes will be saved (or updated for recipes currently residing) in this directory. You can leave these files there and continue to run both scripts for eternity. No need to clean them up. And quite frankly, leaving them alone for backup reasons, is recommended.

Editing the Recipe Files

The file syntax is fairly straightforward. The values are delimited by two caret characters. If there is a quicker or better way to do this, please submit a ticket.

From the first value to last:

  • The unique recipe name (this should never be changed)
  • The path in your repository
  • Is this recipe active or not? 1 being active, 0 being inactive
  • The Bitten recipe itself
  • The minimum revision (if blank, then set to None)
  • The maximum revision (if blank, then set to None)
  • The recipe name as seen on the Trac Bitten Builds page
  • The recipe description

I have seen no harm in changing all but the first value. In fact, I have altered the other values with incorrect data, and was easily able to recover from it, by making my corrections, and running the script again.

Bugs/Feature Requests

Existing bugs and feature requests for BittenRecipesExtractorScript are here.

If you have any issues, create a new ticket.

Known Issues

Pattern matching may include swap and backup specific files from editing your recipes. The only issue this would cause, may be a file with no changes from the original, or other non-desirable changes. Keep this in mind if you are finding recipes not updating with the correct data. Search for hidden files in your recipe directory and delete them. I have attempted to solve this, but unfortunately I have found that Trac allows periods and dashes in the naming convention of Bitten rules. So this rules out a lot of simple pattern matching that can be performed, eg if str.isalnum(file_name).

Super User access is needed when reading and writing to the Trac database directly. Also, on some of my clusters that I work with, multiple version of Python can exist. Hence, if you receive errors like:

ImportError: No module named trac.env

You need to adjust your PATH environment to include the path to the Python version that was used to install and run Trac:

$ export PATH=/usr/local/python2.7/bin:$PATH

Note: This is the reason I do not include the common #!/usr/bin/python interrupter header in my scripts.


Download the zipped source from here.


You can check out BittenRecipesExtractorScript from here using Subversion, or browse the source with Trac.

Recent Changes

11018 by mjasonmiller on 2011-12-05 16:08:09
I give up. Its too early to be coding. But this should fix everything.
11017 by mjasonmiller on 2011-12-05 16:01:49
Sigh. Ignore my last comment...
11016 by mjasonmiller on 2011-12-05 16:00:03
Woops. Fixing simple list issue. I swear to test my code before commiting...


Author: mjasonmiller
Maintainer: Jason Miller

Last modified 2 years ago Last modified on May 21, 2022, 5:08:33 PM