.. automodule:: wizard.install
Classes
--------
-.. autoclass:: OptionParser
+----------------
+.. autoclass:: Strategy
+ :members:
+.. autoclass:: Arg
+.. autoclass:: ArgSet
+.. autoclass:: ArgHandler
:members:
+Predefined classes
+------------------
+.. autoclass:: WebArgSet
+ :show-inheritance:
+.. autoclass:: MysqlArgSet
+ :show-inheritance:
+.. autoclass:: AdminArgSet
+ :show-inheritance:
+.. autoclass:: EmailArgSet
+ :show-inheritance:
+.. autoclass:: ScriptsWebStrategy
+ :members:
+ :show-inheritance:
+.. autoclass:: ScriptsMysqlStrategy
+ :members:
+ :show-inheritance:
+.. autoclass:: ScriptsEmailStrategy
+ :members:
+ :show-inheritance:
+
Functions
---------
.. autofunction:: fetch
.. autofunction:: attr_to_option
-.. autofunction:: calculate_web
-.. autofunction:: calculate_mysql
-.. autofunction:: calculate_email
+.. autofunction:: preloads
Exceptions
----------
.. autoexception:: Error
.. autoexception:: Failure
+ :show-inheritance:
+.. autoexception:: StrategyFailed
+ :show-inheritance:
.. autoexception:: UnrecognizedPreloads
+ :show-inheritance:
+ :members:
.. autoexception:: MissingRequiredParam
+ :show-inheritance:
+ :members:
"""
-This module contains a object model for specifying "required options",
+This module contains an object model for specifying "required options",
also known as "Args". Whereas :class:`optparse.OptionParser` might
normally be configured by performing a bunch of function calls, we
generalize this configuration in order to support other types
manages marshalling these objects to whatever object
is actually managing user input. An argument is any valid Python
variable name, usually categorized using underscores (i.e.
-admin_user); the argument capitalized and with 'WIZARD_' prepended
+admin_user); the argument capitalized and with ``WIZARD_`` prepended
to it indicates a corresponding environment variable, i.e.
-'WIZARD_ADMIN_USER'.
+``WIZARD_ADMIN_USER``.
Because autoinstallers will often have a number of themed
arguments (i.e. MySQL credentials) that are applicable across
There are a number of precanned :class:`ArgSet` subclasses
that serve this purpose, such as :class:`MysqlArgSet`.
:class:`ArgHandler` also contains some convenience syntax in its
-constructor for loading :class:`ArgSet`.
+constructor for loading predefined instances of :class:`ArgSet`.
Certain arguments will vary from install to install, but
can be automatically calculated if certain assumptions about the
"""Performs scripts specific guesses for web variables."""
# XXX: THIS CODE SUCKS
def execute(self, options):
+ """Guesses web path by splitting on web_scripts."""
_, _, web_path = os.getcwd().partition("/web_scripts")
if not web_path:
raise StrategyFailed
class ScriptsMysqlStrategy(Strategy):
"""
- Performs scripts specific guesses for mysql variables. This
+ Performs scripts specific guesses for MySQL variables. This
may create an appropriate database for the user.
"""
side_effects = True
def execute(self, options):
+ """Attempts to create a database using Scripts utilities."""
try:
triplet = subprocess.Popen("/mit/scripts/sql/bin/get-password", stdout=subprocess.PIPE).communicate()[0].rstrip().split()
except:
class ScriptsEmailStrategy(Strategy):
"""Performs script specific guess for email."""
def execute(self, options):
+ """Guesses email using username."""
# XXX: should double-check that you're on a scripts server
# and fail if you're not.
options.email = os.getenv("USER") + "@mit.edu"
Represent a required, named argument for installation. These
cannot have strategies associated with them, so if you'd like
to have a strategy associated with a single argument, create
- set with one item in it.
+ an :class:`ArgSet` with one item in it.
"""
#: Attribute name of the argument
name = None
def envname(self):
"""Name of the environment variable containing this arg."""
return 'WIZARD_' + self.name.upper()
- def __init__(self, name, password=False, type=None, help="XXX: UNDOCUMENTED"):
+ def __init__(self, name, password=False, type=None, help=None):
self.name = name
self.password = password
- self.help = help
+ self.help = help or "UNDOCUMENTED"
self.type = type
class ArgSet(object):
"""
#: List of :class:`ArgSet` objects in schema. The element at
#: index 0 will always be an anonymous :class:`ArgSet` that you
- #: can add stray :class:`Arg`s to.
+ #: can add stray instances of :class:`Arg` to.
argsets = None
def __init__(self, *args):
self.argsets = [ArgSet(), WebArgSet()]
class UnrecognizedPreloads(Error):
"""You passed a preload that was not recognized."""
- #: The preloads that were not recognized
+ #: The preloads that were not recognized.
preloads = None
def __init__(self, preloads):
self.preloads = preloads