From: Edward Z. Yang Date: Tue, 4 May 2010 05:42:59 +0000 (-0400) Subject: Untested alternative support for web stubs. X-Git-Url: https://scripts.mit.edu/gitweb/wizard.git/commitdiff_plain/7aed76163b24be27953b150787285096314b05c9 Untested alternative support for web stubs. Signed-off-by: Edward Z. Yang --- diff --git a/wizard/app/__init__.py b/wizard/app/__init__.py index 87c7b93..4cfd54d 100644 --- a/wizard/app/__init__.py +++ b/wizard/app/__init__.py @@ -141,6 +141,8 @@ class Application(object): #: :class:`wizard.deploy.Deployment`; the value here is merely the preferred #: value. database = None + #: Indicates whether or not a web stub is necessary. + needs_web_stub = False def __init__(self, name): self.name = name self.versions = {} diff --git a/wizard/command/install.py b/wizard/command/install.py index b398265..e5d1465 100644 --- a/wizard/command/install.py +++ b/wizard/command/install.py @@ -12,6 +12,7 @@ def main(argv, baton): appstr = args[0] dir = os.path.abspath(args[1]) + web_stub_path = old_options.web_stub_path if not old_options.retry and not old_options.help and os.path.exists(dir) and os.listdir(dir): raise DirectoryExistsError @@ -19,9 +20,12 @@ def main(argv, baton): appname, _, version = appstr.partition('-') application = app.getApplication(appname) + if application.needs_web_stub and web_stub_path is None: + raise NeedsWebStubError + # get configuration schema = application.install_schema - schema.commit(application, dir) + schema.commit(application, dir, web_stub_path) options = None opthandler = installopt.Controller(dir, schema) parser = command.WizardOptionParser("""usage: %%prog install %s DIR [ -- SETUPARGS ] @@ -49,7 +53,11 @@ Autoinstalls the application %s in the directory DIR.""" % (appname, appname)) if not old_options.retry and version and version != "head-scripts": # for ease in testing shell.call("git", "reset", "-q", "--hard", appstr) input.infobox("Installing...") - application.install(distutils.version.LooseVersion(version), options) + v = distutils.version.LooseVersion(version) + if application.needs_web_stub: + application.install(v, options, web_stub_path) + else: + application.install(v, options) if not old_options.no_commit: git.commit_configure() if not hasattr(options, "web_inferred"): @@ -80,6 +88,9 @@ are required SETUPARGS if you want to run this non-interactively depending on what directory you are installing to.)""" parser = command.WizardOptionParser(usage, store_help=True) configure_parser(parser, baton) + parser.add_option("--web-stub-path", dest="web_stub_path", + default=None, help="Used on certain installations for indicating" + "where to place stub files for a web path.") options, args = parser.parse_all(argv) if options.help: if len(args) == 0: @@ -95,3 +106,7 @@ depending on what directory you are installing to.)""" class DirectoryExistsError(wizard.Error): def __str__(self): return "Directory already exists and is not empty" + +class NeedsWebStubError(wizard.Error): + def __str__(self): + return "You need to specify a web stub directory for this application" diff --git a/wizard/install/__init__.py b/wizard/install/__init__.py index 11b4599..29c6f21 100644 --- a/wizard/install/__init__.py +++ b/wizard/install/__init__.py @@ -117,6 +117,8 @@ class ScriptsWebStrategy(Strategy): self.dir = dir def prepare(self): """Uses :func:`wizard.scripts.get_web_host_and_path`.""" + if self.dir is None: + raise StrategyFailed self._url = scripts.fill_url(self.dir, None) if not self._url: raise StrategyFailed @@ -223,17 +225,6 @@ class WebArgSet(ArgSet): Arg("web_path", type="PATH", help="Relative path to your application root"), ] -class WebStubArgSet(ArgSet): - """ - Common arguments for any application that has an extra folder - necessary to place "stub" code for an application, i.e. a - FastCGI script. Most Python applications will require this. - """ - def __init__(self): - self.args = [ - Arg("web_stub_path", type="PATH", help="Absolute path to the directory containing the web stub"), - ] - class DbArgSet(ArgSet): """Common arguments for applications that use a database.""" def __init__(self): @@ -272,7 +263,6 @@ def preloads(): """ return { 'web': WebArgSet(), - 'webstub': WebStubArgSet(), 'db': DbArgSet(), 'admin': AdminArgSet(), 'email': EmailArgSet(), @@ -285,7 +275,6 @@ class ArgSchema(object): Valid identifiers for subclasses of :class:`ArgSet` are: - * ``webstub``, which populates ``web_stub_path``. * ``db``, which populates the option ``dsn``, which is a SQLAlchemy database source name, with properties for ``drivername``, ``username``, ``password``, ``host``, ``port``, ``database`` and @@ -322,7 +311,7 @@ class ArgSchema(object): def add(self, arg): """Adds an argument to our schema.""" self.args[arg.name] = arg - def commit(self, application, dir): + def commit(self, application, dir, web_stub_path): """Populates :attr:`strategies` and :attr:`provides`""" self.strategies = [] self.provides = set() @@ -330,6 +319,7 @@ class ArgSchema(object): raw_strategies = [ EnvironmentStrategy(self), ScriptsWebStrategy(dir), + ScriptsWebStrategy(web_stub_path), ScriptsMysqlStrategy(application, dir), ScriptsEmailStrategy(), ]