Miscellaneous Modules
Various Pavilion support code modules.
Script Composition
The script composer makes it easy to build up a script with a prescribed environ in a programmatic way.
It also handles translating our module specifications into specific actions to add to the script.
- class pavilion.scriptcomposer.ScriptComposer(header=None)
Bases:
objectManages the building of bash scripts for Pavilion.
- command(command)
Add a line unadulterated to the script lines.
- Parameters:
command (str) – String representing the whole command to add.
- comment(comment)
Function for adding a comment to the script.
- Parameters:
comment (str) – Text to be put in comment without the leading ‘# ‘.
- env_change(env_dict)
Function to take the environment variable change requested by the user and add the appropriate line to the script.
- Parameters:
env_dict (dict) – A dictionary (preferably an OrderedDict) of environment keys and values to set. A value of None will unset the variable.
- module_change(module, sys_vars, config_wrappers)
Take the module changes specified in the user config and add the appropriate lines to the script. This will parse the module name into various actions, find the appropriate module_wrapper plugin, and use that to get the lines to add to the script.
- Parameters:
module (str) – Name of a module or a list thereof in the format used in the user config.
sys_vars – The pavilion system variable dictionary.
config_wrappers – Moduler wrappers specified via config.
- module_purge() None
Add a module purge to the script.
- newline()
Function that just adds a newline to the script lines.
- write(path: Path)
Function to write the script out to file.
- Return bool result:
Returns either True for successfully writing the file or False otherwise.
- exception pavilion.scriptcomposer.ScriptComposerError
Bases:
RuntimeErrorClass level exception during script composition.
- class pavilion.scriptcomposer.ScriptHeader(shebang='#!/bin/bash')
Bases:
objectClass to serve as a struct for the script header.
- get_lines()
Function to retrieve a list of lines for the script header.
- reset()
Function to reset the values of the internal variables back to None.
- property shebang
Function to return the value of the internal shell path variable.
Wget
- pavilion.wget.ca_cert_path()
Try to get system ca certs, then fall back to certifi.
- pavilion.wget.get(pav_cfg, url, dest)
Download the file at the given url and store it at dest. If a file already exists at dest it will be overwritten (assuming we have the permissions to do so). Proxies are handled automatically based on pav_cfg settings. This is done atomically; the download is saved to an intermediate location and then moved. :param pav_cfg: The pavilion configuration object. :param str url: The url for the file to download. :param Path dest: The path to where the file will be stored.
- pavilion.wget.head(pav_cfg, url)
Get the header information for the given url. :param pav_cfg: The pavilion configuration object :param str url: The url we need information on. :returns: The http headers for the given url. :rtype dict:
- pavilion.wget.missing_libs()
You should call this before using the wget module functions, to ensure all the dependencies are available. :returns: A list of one or more missing libraries. It won’t necessarily catch them all in one pass. An empty list is good.
- pavilion.wget.update(pav_cfg, url, dest)
Check if the file needs to be re-downloaded, and do so if necessary. This will create a ‘{dest}.info’ file in the same directory that will be used to check if updates are necessary. :param pav_cfg: The pavilion configuration object. :param str url: The url for the file to download. :param Path dest: The path to where we want to store the file.