modulecmd
index
/remote/sbg_home/jkiser/git/modulecmd/modulecmd.py

Python wrapper to system environment modules.  Basic functions
include:
        load,unload,purge,list,switch,use,unuse
 
To use:
        from modulecmd import Modulecmd
        
        m = Modulecmd()
        m.use("/some/custom/path") # will append to existing
        # load/unload can be called with either a single
        # argument (string) or tuple/list
        m.load("mymod")
        m.load(("mod2","mod3"))
        m.unload("mod2")
        m.switch("mod3","mod3/dev")
        m.list() # shows currently loaded modules
        m.purge() # unloads everything

 
Modules
       
getopt
os
sys
traceback

 
Classes
       
Modulecmd

 
class Modulecmd
     Methods defined here:
__init__(self, modulecmd=None, modulepath=[], verbose=False, modulehome='/global/etc/modules/default')
Modulecmd(<attributes>)
 
attributes:
        modulecmd=<full path to modulecmd>
                if not provided, it will try to find it with $PATH
        modulepath=<path>
                path(s) to add to modulepath.  Can also change
                this on the fly with use/unuse
        verbose=True|False
                Default is False
        modulehome=<path>
                path where MODULEHOME typically resides.  This 
                relies on $MODULEHOME/bin/platform to exist
                to guess the best utility for the current
                platform it is being called from
add(self, *args, **kwargs)
Alias to m.load method
display(self, *args, **kwargs)
Alias for m.show method
list(self)
Usage:
        m.list()
Returns:
        list of all environment modules currently loaded
load(self, mods)
Usage:
        m.load(<module>)
        m.load([<mod1>,<mod2>,etc.])
Returns:
        None
 
Used to add module(s) to current environment.  Input arguments can be either:
        1) String (single module add)
        2) Tuple/List (multiple module add)
modulepaths(self)
Usage:
        m.modulepaths()
Returns:
        list of paths
 
Returns a list of directories that will be traversed to look for modules.  
The environment variable $MODULEPATH is used to find this.  This can
be altered on the fly either by:
        1) Altering $MODULEPATH environment variable (not recommended)
        2) using the use/unuse methods of this class (recommended)
purge(self)
Usage: 
        m.purge()
Returns:
        None
 
Used to unload ALL modules from the current environment
rm(self, *args, **kwargs)
Alias for m.unload method
show(self, mod)
Usage:
        m.show(<module>)
Returns:
        String with information about module.  Doesn't affect environment, directly.
 
Shows information about a given module and the setup that would be taken
if a load is called on it.
swap(self, *args, **kwargs)
Alias for m.switch method
switch(self, m1, m2)
Usage:
        m.switch(<mod1>,<mod1a>)
Returns:
        None
 
Switches the version of a particular module
unload(self, mods)
Usage:
        m.unload(<module>)
        m.unload([<mod1>,<mod2>,etc.])
Returns:
        None
 
Used to remove module(s) from current environment.  Input arguments can be either:
        1) String (single module add)
        2) Tuple/List (multiple module add)
unuse(self, modulepath)
Usage:
        m.unuse(<path>)
        m.unuse([<path1>,<path2>,etc.])
Returns:
        None
 
Alters the $MODULEPATH environment variable by removing paths.  To remove all paths
you can say:
 
        m.unuse(m.modulepaths())
use(self, modulepath)
Usage:
        m.use(<path>)
        m.use([<path1>,<path2>,etc.])
Returns:
        None
 
Alters the $MODULEPATH environment variable by adding paths.