This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#copy of the example script found on mod_wsgi wiki | |
#http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode#Monitoring_For_Code_Changes | |
#am not sure about the licencing but I've created this gist for personal use, making it easy to automate the setup when this is used | |
import os | |
import sys | |
import time | |
import signal | |
import threading | |
import atexit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from fabric.api import * | |
from fabric.contrib.files import append | |
#I've made the assumption that you have git installed | |
env.projectname = 'name_project' #name of your project |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WSGIPythonHome /Users/username/Sites/sitename.tld | |
WSGIRestrictStdout Off | |
WSGIDaemonProcess sitename.tld | |
WSGIProcessGroup sitename.tld | |
<VirtualHost *:80> | |
ServerName sitename.local | |
Alias /site_media/ "/Users/username/Sites/sitename.tld/site-media/" | |
<Directory "/Users/username/Sites/sitename.tld/site-media/"> | |
Order allow,deny |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys | |
sys.path = ['/Users/username/Sites/sitename.tld'] + sys.path | |
os.environ['DJANGO_SETTINGS_MODULE'] = 'sitename.settings' | |
import django.core.handlers.wsgi | |
application = django.core.handlers.wsgi.WSGIHandler() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def local(): | |
"""your local setup""" | |
env.hosts = ['localhost'] | |
env.user = 'username' | |
env.password = 'secret' | |
env.projectname = 'test_project' | |
env.workspace = '/Users/%(username)s/Sites' #name of workspace dir | |
env.path = '%(workspace)s/%(projectname)s' % env | |
env.activate_path = '%(workspace)s/%(projectname)s/bin/activate' % env | |
env.apache_path = '%(path)s/apache' % env |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def setup(): | |
"""docstring for setup""" | |
require('hosts', provided_by=[local]) | |
require('path') | |
with cd(env.workspace): | |
run('virtualenv --no-site-packages %(projectname)s' % env) | |
sudo('easy_install pip', pty=True) | |
run('source %(activate_path)s; pip install django' % env) | |
with cd(env.path): | |
run('source %(activate_path)s; django-admin.py startproject %(projectname)s' % env) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def write_wsgi(): | |
"""docstring for write_wsgi""" | |
file = open("%(apache_path)s/%(projectname)s.wsgi" % env, "w") | |
file.write("import os, sys\nsys.path = ['%(path)s'] + sys.path\n\n\nos.environ['DJANGO_SETTINGS_MODULE'] = '%(projectname)s.settings'\n \n\nimport django.core.handlers.wsgi\napplication = django.core.handlers.wsgi.WSGIHandler()" % env) | |
file.close() | |
def write_conf(): | |
"""docstring for write_conf""" | |
file = open("%(apache_path)s/%(projectname)s.conf" % env, "w") | |
file.write("WSGIPythonHome '%(path)s'\nWSGIRestrictStdout Off\nWSGIDaemonProcess %(projectname)s\nWSGIProcessGroup %(projectname)s\n\n<VirtualHost *:80>\n ServerName %(projectname)s.local\n Alias /site_media/ '%(apache_path)s/public/site_media'\n<Directory '%(apache_path)s/public/site_media'>\n Order allow,deny\n Options Indexes\n Allow from all\n\n</Directory>\n\n\n\nAlias /media/ '%(path)s/lib/python2.6/site-packages/django/contrib/admin/media/'\n<Directory '%(path)s/python2.6/site-packages/django/contrib/admin/media/'>\n Orde |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def enable_site(): | |
"""this enable your site using httpd.conf""" | |
append('#enabling %(projectname)s\nInclude %(apache_path)s/%(projectname)s.conf\n' % env,'%(httpd)s' % env, use_sudo=True) | |
append('%(ip)s %(projectname)s.local' % env, '/etc/hosts', use_sudo=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_monitor(): | |
"""download and enable auto restart of wsgi""" | |
run('cd %(path)s;git clone git://gist.github.com/258020.git gist-258020' % env) | |
run('cd %(path)s/gist-258020; mv monitor.py %(path)s/%(projectname)s/; rm -rf %(path)s/gist-258020' % env) | |
append("\nimport %(projectname)s.monitor\n%(projectname)s.monitor.start(interval=1.0)" % env,"%(apache_path)s/%(projectname)s.wsgi" % env) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import urllib | |
""" | |
strip html tags from a webpage | |
need's regex to remove js too | |
""" | |
url = '' |
OlderNewer