sprinter Package

directory Module

directory.py stores methodology to install various files and packages to different locations.

class sprinter.directory.Directory(namespace=None)[source]

Bases: object

add_to_rc(content)[source]

add content to the rc script.

bin_path()[source]

return the bin directory path

config_path()[source]

return writable handle to config file

install_directory(feature_name)[source]

return a path to the install directory that the feature should install to.

lib_path()[source]

return the lib directory path

Symlink an object at path to name in the bin folder. remove it if it already exists.

Symlink an object at path to name in the lib folder. remove it if it already exists.

environment Module

A module that completely encapsulates a class. This should be a complete object representing any data needed by recipes.

class sprinter.environment.Environment(namespace=None, logger=None, logging_level=20)[source]

Bases: object

activate()[source]

activate environment specific injections

add_to_rc(content)[source]
clear(filename)[source]
commit_injections(filename, content)[source]
context()[source]

get a context dictionary to replace content

deactivate()[source]

deactivate environments

destroys()[source]
finalize()[source]

command to run at the end of sprinter’s run

get_config(param_name, default=None, temporary=False)[source]
grab_inputs()[source]
inject(filename, content)[source]
install_directory(feature_name)[source]
isDebianBased()[source]
isFedoraBased()[source]
isLinux()[source]
isOSX()[source]
load_manifest(target_manifest, source_manifest=None)[source]
load_namespace(namespace=None)[source]
load_target_implicit()[source]
rc_path()[source]
recipe_dict = {}
reloads()[source]
setups()[source]
updates()[source]
validate()[source]
validate_context(content)[source]

check if all the config variables desired exist, and prompt them if not

injections Module

Injections.py handles injections into various configuration files throughout files on the file system. These operations are batched and applied together.

class sprinter.injections.Injections(wrapper)[source]

Bases: object

Injections are staged until they are committed with the commit() method. This allow for aggregations until the commiting is ready to be performed.

clear(filename)[source]

add the file to the list of files to clear

clear_dict = set([])
commit()[source]

commit the injections desired, overwriting any previous injections in the file.

inject(filename, content)[source]

add the injection content to the dictionary

inject_dict = {}
logger = None
wrapper = None

install Module

The install script for a sprinter-based setup script.

sprinter.install.main()[source]

lib Module

Library module for sprinter. To handle a lot of the typical features of the library.

sprinter.lib.call(command)[source]
sprinter.lib.get_recipe_class(recipe, environment)[source]

Get the recipe name and return an instance The recipe path is a path to the module. get_recipe_class performs reflection to find the first class that extends recipebase, and that is the class that an instance of it gets returned.

>>> issubclass(get_recipe_class("sprinter.recipes.unpack").__class__, RecipeBase)
True
sprinter.lib.prompt(prompt_string, default=None, secret=False)[source]

Prompt user for a string, with a default value

manifest Module

manifest.py is a utility class to help determine version differences in sprinter apps.

example manifest sections look like: [FEATURE] version = {{ manifest_version }} {{ configuration vars }}

class sprinter.manifest.Manifest(target_manifest=None, source_manifest=None, namespace=None)[source]

Bases: object

Class to represent a manifest object

>>> m.namespace
'sprinter'
activations()[source]

Return a dictionary of activation recipes.

>>> m.activations()
{'myrc': {'target': {'recipe': 'sprinter.recipes.template'}}}
config = {}
deactivations()[source]

Return a dictionary of activation recipes.

>>> m.activations()
{'myrc': {'target': {'recipe': 'sprinter.recipes.template'}}}
destroys()[source]

Return a dictionary with all the features that need to be destroyed. >>> m.destroys() {‘mysql’: {‘source’: {‘brew’: ‘mysql’, ‘apt-get’: ‘libmysqlclientnlibmysqlclient-dev’, ‘recipe’: ‘sprinter.recipes.package’}}}

get_config(param_name, default=None, secret=False)[source]

grabs a config from the user space; if it doesn’t exist, it will prompt for it.

get_context_dict()[source]

return a context dict of the desired state

grab_inputs()[source]

Look for any inputs not already asked accounted for, and query the user for them.

load_source(source_manifest)[source]

reload the source manifest

load_target(target_manifest)[source]

reload the source manifest

load_target_implicit()[source]

Attempt an implicit load of a target file. An implicit load involves looking at source manifest’s config:source parameter and attempting to load from there. If that’s not possible, false is returned.

reloads()[source]

return reload dictionaries

setups()[source]

Return a dictionary with all the features that need to be setup. >>> m.setups() {‘myrc’: {‘target’: {‘recipe’: ‘sprinter.recipes.template’}}}

source_manifest = <ConfigParser.RawConfigParser instance at 0x10c8e9f38>
source_sections()[source]

return all source sections except for reserved ones

target_manifest = None
target_sections()[source]

return all target sections except for reserved ones

temporary_sections = []
updates()[source]

Return a dictionary with all the features that need to be updated.

>>> m.updates()
{'maven': {'source': {'recipe': 'sprinter.recipes.unpack', 'specific_version': '2.10'}, 'target': {'recipe': 'sprinter.recipes.unpack', 'specific_version': '3.0.4'}}}
>>> m_old_only.updates()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ManifestError: Update method requires a target manifest!
validate()[source]

Checks validity of manifest files.

write(file_handle)[source]

write the current state to a file manifest

exception sprinter.manifest.ManifestError[source]

Bases: exceptions.Exception

recipebase Module

Recipe base is an abstract base class outlining the method required and some documentation on what they should provide.

class sprinter.recipebase.RecipeBase(environment)[source]

Bases: object

activate(feature_name, config)[source]

function to run when activating

deactivate(feature_name, config)[source]

tasks to run when deactivating

destroy(feature_name, old_config)[source]

Destroys an old feature if it is no longer required

reload(feature_name, config)[source]

tasks to call when reloading

setup(feature_name, config)[source]

Setup performs the setup required, with the config specified

update(feature_name, config)[source]

Setup performs the setup required, and works with the old config is destruction is required

recipestandard Module

Recipe base is an abstract base class outlining the method required and some documentation on what they should provide.

class sprinter.recipestandard.RecipeStandard(environment)[source]

Bases: sprinter.recipebase.RecipeBase

destroy(feature_name, config)[source]

Destroys an old feature if it is no longer required

setup(feature_name, config)[source]

Setup performs the setup required, with the config specified

update(feature_name, config)[source]

Setup performs the setup required, and works with the old config is destruction is required