]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/command/install.py
Convert ad hoc shell calls to singleton instance; fix upgrade bug.
[wizard.git] / wizard / command / install.py
index 87af9866b49bdad53fec64132498b0a1760d8038..4ae9058a3880953f3568fb41c57a7c9158fb90f5 100644 (file)
@@ -14,7 +14,7 @@ def main(argv, baton):
     appstr = args[0]
     dir = os.path.abspath(args[1])
 
-    if not old_options.help and os.path.exists(dir) and os.listdir(dir):
+    if not old_options.retry and not old_options.help and os.path.exists(dir) and os.listdir(dir):
         raise DirectoryExistsError
 
     appname, _, version = appstr.partition('-')
@@ -22,10 +22,9 @@ def main(argv, baton):
 
     # get configuration
     schema = application.install_schema
-    schema.commit(dir)
+    schema.commit(application, dir)
     options = None
     opthandler = installopt.Controller(dir, schema)
-    ihandler = interactive.Controller(dir, schema, input)
     parser = command.WizardOptionParser("""usage: %%prog install %s DIR [ -- SETUPARGS ]
 
 Autoinstalls the application %s in the directory DIR.""" % (appname, appname))
@@ -34,22 +33,25 @@ Autoinstalls the application %s in the directory DIR.""" % (appname, appname))
     if old_options.help:
         parser.print_help()
         sys.exit(1)
+    ihandler = interactive.Controller(dir, schema, input)
     options, _ = parser.parse_all(args[2:] + command.make_base_args(old_options))
     if old_options.non_interactive:
         opthandler.handle(options)
     else:
         ihandler.ask(options)
 
-    sh = shell.Shell()
     input.infobox("Copying files (this may take a while)...")
-    sh.call("git", "clone", "-q", "--shared", application.repository(old_options.srv_path), dir)
+    if not os.path.exists(dir):
+        shell.call("git", "clone", "-q", "--shared", application.repository(old_options.srv_path), dir)
     with util.ChangeDirectory(dir):
-        if version and version != "head-scripts": # for ease in testing
-            sh.call("git", "reset", "-q", "--hard", appstr)
+        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)
         if not old_options.no_commit:
             git.commit_configure()
+    if not hasattr(options, "web_inferred"):
+        open(os.path.join(dir, ".scripts/url"), "w").write("http://%s%s" % (options.web_host, options.web_path)) # XXX: no support for https yet!
     input.infobox("Congratulations, your new install is now accessible at:\n\nhttp://%s%s" % (options.web_host, options.web_path), width=80)
 
 def configure_parser(parser, baton):
@@ -59,6 +61,8 @@ def configure_parser(parser, baton):
             default=False, help="Force program to be non-interactive and use SETUPARGS.  Use --help with APP to find argument names.")
     parser.add_option("--no-commit", dest="no_commit", action="store_true",
             default=command.boolish(os.getenv("WIZARD_NO_COMMIT")), help="Do not generate an 'installation commit' after configuring the application. Envvar is WIZARD_NO_COMMIT")
+    parser.add_option("--retry", dest="retry", action="store_true",
+            default=False, help="Do not complain if directory already exists and reinstall application.")
     baton.push(parser, "srv_path")
 
 def parse_args(argv, baton):