From 99f87f63cd86b8c6ac7678cc09365b27b75ea8de Mon Sep 17 00:00:00 2001 From: "j.c.sackett" Date: Thu, 16 Jul 2009 21:27:25 -0400 Subject: [PATCH] build now creates the apache file. i simplified settings.py.tmpl some to match what i do in deploys. i can always introduce more complexity later. --- templates/settings.py.tmpl | 13 +++------ weaver.py | 54 ++++++++++++++++++++++++++++++++------ 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/templates/settings.py.tmpl b/templates/settings.py.tmpl index cc26798..34d6359 100644 --- a/templates/settings.py.tmpl +++ b/templates/settings.py.tmpl @@ -2,24 +2,19 @@ PROJECT_HOME = '' #the name of the directory the project will be hosted under CODE_HOME = '' #the name of the directory the code will be hosted in REPO_TYPE = '' #one of git, hg, or svn -REPO = '' +REPO = '' #the url of the code repo +USER = '' #The user for the server #SERVER BASED SETUP INFO # Each of the following variables consists of a three part tuple, defining # that variable for each server in STAGING, INTERNAL, and PRODUCTION -LIGHTTPD_USER = ('', '', '') #The lighty user for the server (e.g. www-data) -APACHE_USER = ('', '', '') #The apache user for the server (e.g. www-data) ADMIN = ('', '', '') #The admin email for the apache instance (e.g. webmaster@example.com) - MYSQL_USER = ('', '', '') #The mysql user for the project MYSQL_PASSWORD = ('', '', '') #The password for the mysql user on the project SERVER = ('', '', '') #The ip or servername for the server -USER = ('', '', '') #The user for the server -SITE_URL = ('', '', '') #The url the site is hosted at on the server (http://example.com, http://example.com:8080, http://bad.example.com) -APACHE_PORT = ('', '', '') #The port apache is listening on +URL = ('', '', '') #The url the site is hosted at on the server (http://example.com, http://example.com:8080, http://bad.example.com) +PORT = ('', '', '') #The port apache is listening on DJANGO_PROCESS = ('', '', '') #The process daemon for the wsgi django handler -OWNER = ('', '', '') #The user who should own the site files, logs, etc -GROUP = ('', '', '') #The group who should own the site files, logs, etc diff --git a/weaver.py b/weaver.py index 9efa1f8..16f4103 100755 --- a/weaver.py +++ b/weaver.py @@ -38,29 +38,44 @@ def load_settings(): config.project = getattr(settings, 'PROJECT_HOME') config.code = getattr(settings, 'CODE_HOME') + config.user = getattr(settings, 'USER') + config.repo = getattr(settings, 'REPO') + config.repo_type = getattr(settings, 'REPO_TYPE') - config.url = getattr(settings, 'SITE_URL') + config.url = getattr(settings, 'URL') config.url = dict( staging='^%s$' % '\.'.join(config.url[0].split('.')), internal='^%s$' % '\.'.join(config.url[1].split('.')), production='^%s$' % '\.'.join(config.url[2].split('.')), ) - config.port = getattr(settings, 'APACHE_PORT') + config.port = getattr(settings, 'PORT') config.port = dict( staging=config.port[0], internal=config.port[1], production=config.port[2] ) + config.admin = getattr(settings, 'ADMIN') + config.admin = dict( + staging=config.admin[0], + internal=config.admin[1], + production=config.admin[2] + ) + config.django_process = getattr(settings, 'DJANGO_PROCESS') + config.django_process = dict( + staging=config.django_process[0], + internal=config.django_process[1], + production=config.django_process[2] + ) def scripts(): os.mkdir('scripts') template = env.get_template('scripts/setup_directories.sh.tmpl') - content = template.render(PROJECT=config.project) + content = template.render(project=config.project) file(os.path.join('scripts', 'setup_directories.sh'), 'w').write(content) template = env.get_template('scripts/setup_syslinks.sh.tmpl') - content = template.render(PROJECT=config.project, CODE=config.code) + content = template.render(project=config.project, code=config.code) file(os.path.join('scripts', 'setup_syslinks.sh'), 'w').write(content) def conf(): @@ -84,6 +99,28 @@ def conf(): file(os.path.join('conf', 'production', filename), 'w').write(production_content) file(os.path.join('conf', 'internal', filename), 'w').write(internal_content) + template = env.get_template('conf/apache.tmpl') + staging_content = template.render(project=config.project, + port=config.port['staging'], + djangoprocess=config.django_process['staging'], + admin=config.admin['staging'], + code=config.code) + production_content = template.render(project=config.project, + port=config.port['production'], + djangoprocess=config.django_process['production'], + admin=config.admin['production'], + code=config.code) + internal_content = template.render(project=config.project, + port=config.port['internal'], + djangoprocess=config.django_process['internal'], + admin=config.admin['internal'], + code=config.code) + filename = '%s' % config.project + file(os.path.join('conf', 'staging', filename), 'w').write(staging_content) + file(os.path.join('conf', 'production', filename), 'w').write(production_content) + file(os.path.join('conf', 'internal', filename), 'w').write(internal_content) + + commands = { 'init':init, 'build':build @@ -93,7 +130,8 @@ def conf(): cmd = sys.argv[1] args = sys.argv[2:] - try: - commands[cmd](args) - except KeyError: - print '%s is not a weaver command.' % cmd \ No newline at end of file + c = commands.get(cmd, None) + if c is None: + print '%s is not a weaver command.' % cmd + else: + c(args) \ No newline at end of file