6 from wizard import app, command, git, prompt, shell, util
7 from wizard.install import installopt, interactive
10 old_options, args = parse_args(argv, baton)
12 input = prompt.make(old_options.prompt, old_options.non_interactive)
17 if os.path.exists(dir) and os.listdir(dir):
18 raise DirectoryExistsError
20 appname, _, version = appstr.partition('-')
21 application = app.applications()[appname]
24 schema = application.install_schema
26 opthandler = installopt.Controller(dir, schema)
27 ihandler = interactive.Controller(dir, schema, input)
28 parser = command.WizardOptionParser()
29 opthandler.push(parser)
30 options, _ = parser.parse_all(args[2:] + command.make_base_args(old_options)) # accumulate
31 if old_options.non_interactive:
32 opthandler.handle(options)
37 input.infobox("Copying files (this may take a while)...")
38 sh.call("git", "clone", "-q", "--shared", application.repository(old_options.srv_path), dir)
39 with util.ChangeDirectory(dir):
41 # XXX: do something smart if -scripts is not at the end
42 sh.call("git", "reset", "-q", "--hard", appstr)
43 input.infobox("Installing...")
44 application.install(distutils.version.LooseVersion(version), options)
45 git.commit_configure()
46 input.infobox("Congratulations, your new install is now accessible at http://%s%s" % (options.web_host, options.web_path))
48 def parse_args(argv, baton):
49 usage = """usage: %prog install APP DIR [ -- SETUPARGS ]
51 Autoinstalls the application APP in the directory
52 DIR. SETUPARGS are arguments that are passed to
53 'wizard configure', see 'wizard configure APP --help'
54 for possible arguments. If arguments are missing
55 this command will interactively ask for them.
57 parser = command.WizardOptionParser(usage)
58 parser.add_option("--prompt", dest="prompt", action="store_true",
59 default=False, help="Force to use non-ncurses interactive interface")
60 parser.add_option("--non-interactive", dest="non_interactive", action="store_true",
61 default=False, help="Force program to be non-interactive")
62 baton.push(parser, "srv_path")
63 options, args = parser.parse_all(argv)
65 parser.error("not enough arguments")
68 class DirectoryExistsError(wizard.Error):
70 return "Directory already exists and is not empty"