]> scripts.mit.edu Git - wizard.git/blob - wizard/app/wordpress.py
Implement Wordpress installer for 2.0.2 w/ sqlalchemy.
[wizard.git] / wizard / app / wordpress.py
1 import sqlalchemy
2 import os
3
4 from wizard import app, install, sql
5 from wizard.app import php
6
7 class Application(app.Application):
8     install_schema = install.ArgSchema("mysql", "email", "title")
9     def download(self, version):
10         return "http://wordpress.org/wordpress-%s.tar.gz" % version
11     def install(self, version, options):
12         post_setup_config = {
13                 'dbhost': options.mysql_host,
14                 'uname': options.mysql_user,
15                 'dbname': options.mysql_db,
16                 'pwd': options.mysql_password,
17                 'prefix': '',
18                 'submit': 'Submit',
19                 'step': '2',
20                 }
21         post_install = {
22                 'weblog_title': options.title,
23                 'admin_email': options.email,
24                 'submit': 'Continue',
25                 'step': '2',
26                 }
27         old_mode = os.stat(".").st_mode
28         os.chmod(".", 0777) # XXX: squick squick
29         install.fetch(options, "wp-admin/setup-config.php?step=2", post_setup_config)
30         result = install.fetch(options, "wp-admin/install.php?step=2", post_install)
31         os.chmod(".", old_mode)
32         if "Finished" not in result:
33             raise install.Failure()
34
35         # not sure what to do about this
36         meta = sql.mysql_connect(options)
37         wp_options = meta.tables["wp_options"]
38         wp_options.update().where(wp_options.c.option_name == 'siteurl').values(option_value=options.web_path).execute()
39         wp_options.update().where(wp_options.c.option_name == 'home').values(option_value="http://%s%s" % (options.web_host, options.web_path)).execute() # XXX: what if missing leading slash; this should be put in a function