Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: blturner/stitch
base: 09b713e12b
...
head fork: blturner/stitch
compare: c8db58d587
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
View
32 stitch/fabfile.py
@@ -1,4 +1,3 @@
-import collections
import os
import pprint
import shutil
@@ -12,6 +11,8 @@
from fabric.operations import put
from jinja2 import Environment, FileSystemLoader
+from stitch.helpers import update
+
"""
Usage:
`fab stage`
@@ -56,21 +57,6 @@ def render_jinja(template, context, filename):
f.write(t.render(c))
-def update(d, u):
- """
- Utility function that takes a dictionary and updates keys with values from a
- second dictionary.
- http://stackoverflow.com/a/3233356
- """
- for k, v in u.iteritems():
- if isinstance(v, collections.Mapping):
- r = update(d.get(k, {}), v)
- d[k] = r
- else:
- d[k] = u[k]
- return d
-
-
def restart():
if is_local(env.host):
local('sudo apachectl graceful')
@@ -167,7 +153,7 @@ def generate_conf(template_name, dest, filename, context={}):
if not local_or_remote_exists(dest):
local_or_remote('mkdir -p %s' % dest)
- target = '/'.join((dest, filename))
+ target = os.path.join(dest, filename)
if is_local(env.host):
f = open(target, 'w')
@@ -181,19 +167,19 @@ def generate_conf(template_name, dest, filename, context={}):
def generate_confs():
host = get_host_shortname(env.host)
host_dict = get_host_dict(env.host)
- apache_dir = '/'.join((host_dict.get('apache_dir'), host))
+ apache_dir = os.path.join(host_dict.get('apache_dir'), host)
staging_domain = host_dict.get('staging_domain')
virtualenv_dir = host_dict.get('virtualenv_dir')
wsgi_dir = host_dict.get('wsgi_dir')
for site in get_sites():
context = {
- 'admin_media': '/'.join((get_site_packages(site), 'django/contrib/admin/media')),
+ 'admin_media': os.path.join(get_site_packages(site), 'django/contrib/admin/media'),
'pypath': get_site_settings(site).get('pythonpath').get(host, []),
'site': site,
'sitepackages': get_site_packages(site),
'staging_domain': staging_domain,
- 'virtualenv_dir': '/'.join((virtualenv_dir, site)),
+ 'virtualenv_dir': os.path.join(virtualenv_dir, site),
'wsgi_dir': wsgi_dir
}
generate_conf('apache/base.conf', apache_dir, '%s.conf' % site, context)
@@ -202,8 +188,8 @@ def generate_confs():
def init_settings_dir(path):
- init_file = '/'.join((path, '__init__.py'))
- mgmt_file = '/'.join((path, 'manage.py'))
+ init_file = os.path.join(path, '__init__.py')
+ mgmt_file = os.path.join(path, 'manage.py')
if not local_or_remote_exists(init_file):
if is_local(env.host):
@@ -230,7 +216,7 @@ def generate_settings(site):
host_dict = get_host_dict(env.host)
pp = pprint.PrettyPrinter()
settings_dir = host_dict.get('staging_settings')
- site_settings = '/'.join((settings_dir, site))
+ site_settings = os.path.join(settings_dir, site)
if not local_or_remote_exists(site_settings):
local_or_remote('mkdir -p %s' % site_settings)
init_settings_dir(site_settings)
View
16 stitch/helpers.py
@@ -0,0 +1,16 @@
+import collections
+
+
+def update(d, u):
+ """
+ Utility function that takes a dictionary and updates keys with values from a
+ second dictionary.
+ http://stackoverflow.com/a/3233356
+ """
+ for k, v in u.iteritems():
+ if isinstance(v, collections.Mapping):
+ r = update(d.get(k, {}), v)
+ d[k] = r
+ else:
+ d[k] = u[k]
+ return d
View
18 stitch/templates/wsgi/base.conf
@@ -0,0 +1,18 @@
+import os, site, sys
+
+activate_this = '{{ virtualenv_dir }}/bin/activate_this.py'
+execfile(activate_this, dict(__file__=activate_this))
+
+{% if pypath %}sys.path[:0] = {{ pypath }}{% endif %}
+
+# Loaded after the virtualenv is activated
+try:
+ from staging import wsgi_reloader
+ wsgi_reloader.start(interval=1.0)
+except:
+ pass
+
+os.environ['DJANGO_SETTINGS_MODULE'] = '{{ site }}.settings'
+
+import django.core.handlers.wsgi
+application = django.core.handlers.wsgi.WSGIHandler()

No commit comments for this range

Something went wrong with that request. Please try again.