Skip to content

Commit

Permalink
so much flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithan committed Apr 8, 2013
1 parent 825324c commit 1c0dfc5
Show file tree
Hide file tree
Showing 59 changed files with 1,097 additions and 783 deletions.
24 changes: 15 additions & 9 deletions deploy/fab/fabfile.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import os

from fabric.api import *
from fabric.api import cd, env, put, run, sudo
import fabtools

cwd = os.getcwd()
all_users = ['docs', 'builder']
required_dirs = ['checkouts', 'etc', 'run', 'log']


def all():
install_packages('build')
install_packages('web')
Expand All @@ -15,12 +16,14 @@ def all():
checkout('docs')
setup_env('docs')


def build():
install_packages('build')
users('docs')
checkout('docs')
setup_env('docs')


def web():
install_packages('web')
users('docs')
Expand All @@ -42,9 +45,9 @@ def install_packages(type):
sudo(
'apt-get install -y git-core python-dev '
'postgresql-client libpq-dev subversion graphviz '
'curl sqlite libxml2-dev libxslt-dev vim g++ python-numpy python-scipy '
'build-essential texlive-full libevent-dev libmysqlclient-dev '
'python-m2crypto'
'curl sqlite libxml2-dev libxslt-dev vim g++ python-numpy '
'python-scipy build-essential texlive-full libevent-dev '
'libmysqlclient-dev python-m2crypto'
)
sudo('pip install -U mercurial')
if type == 'db':
Expand All @@ -53,7 +56,6 @@ def install_packages(type):
sudo('apt-get install -y nginx')



def users(user=None):
if user:
users = [user]
Expand All @@ -66,7 +68,8 @@ def users(user=None):

if not fabtools.files.is_file('%s/.ssh/authorized_keys' % home):
sudo('mkdir -p %s/.ssh' % home)
put('keys/*.pub', '%s/.ssh/authorized_keys' % home, mode=700, use_sudo=True)
put('keys/*.pub', '%s/.ssh/authorized_keys' % home, mode=700,
use_sudo=True)
sudo('chown -R %s:%s %s' % (user, user, home))
sudo('chmod -R 700 %s' % home)
sudo('mkdir -p /var/build')
Expand All @@ -90,7 +93,8 @@ def checkout(user=None):
run('git clone git://github.com/rtfd/readthedocs.org.git')
if not fabtools.files.is_file('%s/bin/python' % home):
run('virtualenv %s' % home)
run('%s/bin/pip install -U -r %s/checkouts/readthedocs.org/deploy_requirements.txt' % (home, home))
run(('%s/bin/pip install -U -r %s/checkouts/readthedocs.org/'
'deploy_requirements.txt') % (home, home))


def setup_env(user=None):
Expand All @@ -102,10 +106,11 @@ def setup_env(user=None):
env.user = user
home = '/home/%s' % user
put('files/bash_profile', '%s/.bash_profile' % home)
put('files/%s_supervisord.conf' % user, '%s/etc/supervisord.conf' % home)
#put('files/%s_local_settings.py' % user, '%s/checkouts/readthedocs.org/readthedocs/settings/local_settings.py' % home)
put('files/%s_supervisord.conf' % user,
'%s/etc/supervisord.conf' % home)
run('%s/bin/pip install -U supervisor ipython gunicorn' % home)


def fix_perms(user=None):
if user:
users = [user]
Expand All @@ -116,6 +121,7 @@ def fix_perms(user=None):
home = '/home/%s' % user
sudo('chown -R %s:%s %s' % (user, user, home))


def setup_db():
env.user = "docs"
home = '/home/%s' % env.user
Expand Down
6 changes: 5 additions & 1 deletion deploy/fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,27 @@

def install_chef():
sudo('apt-get update', pty=True)
sudo('apt-get install -y git-core libopenssl-ruby rubygems ruby ruby-dev', pty=True)
sudo('apt-get install -y git-core libopenssl-ruby rubygems ruby ruby-dev',
pty=True)
#sudo('gem install chef --no-ri --no-rdoc', pty=True)
sudo('gem install chef --no-ri --no-rdoc --version=0.10.2', pty=True)


def sync_config():
local('rsync -av . %s@%s:/etc/chef' % (env.user, env.hosts[0]))


def update():
sync_config()
sudo('cd /etc/chef && %s' % env.chef_executable, pty=True)


def reload():
"Reload the server."
env.user = "docs"
run("kill -HUP `cat %s/gunicorn.pid`" % env.rundir, pty=True)


def restart():
"Restart (or just start) the server"
sudo('restart readthedocs-gunicorn', pty=True)
6 changes: 3 additions & 3 deletions docs/_ext/djangodocs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
def setup(app):
app.add_crossref_type(
directivename = "setting",
rolename = "setting",
indextemplate = "pair: %s; setting",
directivename="setting",
rolename="setting",
indextemplate="pair: %s; setting",
)
27 changes: 15 additions & 12 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# -*- coding: utf-8 -*-
#
import sys, os
import os
import sys

sys.path.insert(0, os.path.abspath('../readthedocs'))
import settings.sqlite
from django.core.management import setup_environ
setup_environ(settings.sqlite)


sys.path.append(os.path.abspath('_ext'))
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx_http_domain',
'djangodocs',
]
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx_http_domain',
'djangodocs',
]
templates_path = ['_templates']
source_suffix = '.rst'
master_doc = 'index'
Expand All @@ -24,10 +27,10 @@
default_role = 'obj'
pygments_style = 'sphinx'
intersphinx_mapping = {
'python': ('http://python.readthedocs.org/en/latest/', None),
'django': ('http://django.readthedocs.org/en/latest/', None),
'sphinx': ('http://sphinx.readthedocs.org/en/latest/', None),
}
'python': ('http://python.readthedocs.org/en/latest/', None),
'django': ('http://django.readthedocs.org/en/latest/', None),
'sphinx': ('http://sphinx.readthedocs.org/en/latest/', None),
}
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
if on_rtd:
html_theme = 'default'
Expand All @@ -36,8 +39,8 @@
html_static_path = ['_static']
htmlhelp_basename = 'ReadTheDocsdoc'
latex_documents = [
('index', 'ReadTheDocs.tex', u'Read The Docs Documentation',
u'Eric Holscher, Charlie Leifer, Bobby Grace', 'manual'),
('index', 'ReadTheDocs.tex', u'Read The Docs Documentation',
u'Eric Holscher, Charlie Leifer, Bobby Grace', 'manual'),
]
man_pages = [
('index', 'read-the-docs', u'Read The Docs Documentation',
Expand Down
17 changes: 13 additions & 4 deletions fabfile-development.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from fabric.api import *
from fabric.api import cd, env, prefix, run, sudo, task

# Fill out USER and HOSTS configuration before running
env.user = ''
Expand All @@ -7,37 +7,45 @@
env.code_dir = '/home/%s/rtd/checkouts/readthedocs.org' % (env.user)
env.virtualenv = '/home/%s/rtd' % (env.user)


def install_prerequisites():
"""Install prerequisites."""
sudo("apt-get -y install python-dev python-pip git redis-server texlive texlive-latex-extra")
sudo("apt-get -y install python-dev python-pip git redis-server texlive "
"texlive-latex-extra")
sudo("pip install virtualenv")


def create_virtualenv():
"""Create virtualenv."""
run("virtualenv --no-site-packages --distribute rtd")


def clone_repository():
"""Clone readthedocs repo"""
run("mkdir %s/checkouts" % (env.virtualenv))
with cd("%s/checkouts" % env.virtualenv):
run("git clone http://github.com/rtfd/readthedocs.org.git")


def pip_requirements():
"""Install pip requirements"""
with cd(env.code_dir):
with prefix("source %s/bin/activate" % (env.virtualenv)):
run("pip install -r pip_requirements.txt")


def build_db():
"""Build database"""
with prefix("source %s/bin/activate" % (env.virtualenv)):
run("%s/readthedocs/manage.py syncdb" % (env.code_dir))


def migrate_db():
"""Migrate database"""
with prefix("source %s/bin/activate" % (env.virtualenv)):
run("%s/readthedocs/manage.py migrate" % (env.code_dir))


def load_testprojects():
"""Load test data and update repos"""
with prefix("source %s/bin/activate" % (env.virtualenv)):
Expand All @@ -56,11 +64,12 @@ def install():
migrate_db()
load_testprojects()


@task
def clean():
"""Clean up everything to start over"""
sudo("rm -rf %s" % (env.virtualenv))
sudo("pip uninstall virtualenv")
sudo("apt-get -y purge python-dev python-pip git redis-server texlive texlive-latex-extra")
sudo("apt-get -y purge python-dev python-pip git redis-server texlive "
"texlive-latex-extra")
sudo("apt-get -y autoremove --purge")

Loading

0 comments on commit 1c0dfc5

Please sign in to comment.