new file: api.pyc new file: conf/fabric.yml new file: fabfile.py new file: fabfile.pyc new file: modules/__init__.py new file: modules/__init__.pyc new file: modules/conf_setup.py new file: modules/conf_setup.pyc new file: modules/configuration_setup.py new file: modules/database.py new file: modules/database.pyc new file: modules/deploy.py new file: modules/deploy.pyc new file: modules/django.py new file: modules/django.pyc new file: modules/docker.py new file: modules/docker.pyc new file: modules/initialize.py new file: modules/initialize.pyc new file: modules/maintenance.py new file: modules/maintenance.pyc new file: modules/nginx.py new file: modules/nginx.pyc new file: modules/pip.py new file: modules/pip.pyc new file: modules/setup.pyc new file: modules/supervisor.py new file: modules/supervisor.pyc new file: modules/testing/__init__.py new file: modules/testing/__init__.pyc new file: modules/testing/configuration_setup.py new file: modules/testing/maintenance.pyc new file: modules/utils.py new file: modules/utils.pyc new file: templates/conf/database/files/db.drop_all.sql.jinja2 new file: templates/conf/database/files/db.drop_db.sql.jinja2 new file: templates/conf/database/files/db.init.sql.jinja2 new file: templates/conf/database/files/db.re_init.sql.jinja2 new file: templates/conf/django/files/gunicorn.jinja2 new file: templates/conf/django/files/gunicorn.unixsocket.jinja2 new file: templates/conf/django/files/local.jinja2 new file: templates/conf/django/files/settings.jinja2 new file: templates/conf/django/files/settings18.jinja2 new file: templates/conf/django/files/wsgi.jinja2 new file: templates/conf/django/files/wsgi.py new file: templates/conf/docker/files/database.jinja2 new file: templates/conf/gunicorn/files/gunicorn.jinja2 new file: templates/conf/gunicorn/files/gunicorn.unixsocket.jinja2 new file: templates/conf/gunicorn/files/local.jinja2 new file: templates/conf/gunicorn/files/settings.jinja2 new file: templates/conf/gunicorn/files/settings18.jinja2 new file: templates/conf/gunicorn/files/wsgi.jinja2 new file: templates/conf/gunicorn/files/wsgi.py new file: templates/conf/nginx/files/default.conf.jinja2 new file: templates/conf/nginx/files/unixsocket.jinja2 new file: templates/conf/supervisor/files/conf_old new file: templates/conf/supervisor/files/supervisor.jinja2 new file: templates/meta/development.yml new file: templates/meta/layout.yml new file: templates/meta/staging.yml new file: templates/readmes/aws.md new file: templates/readmes/gandi.md new file: templates/readmes/reset_migrations.md new file: templates/readmes/setup_gandi.md new file: templates/readmes/translations.md new file: templates/readmes/update_images.md
181 lines
5.1 KiB
Python
181 lines
5.1 KiB
Python
from fabric.api import task, env
|
|
from fabric.operations import run
|
|
import os
|
|
import modules.utils as utils
|
|
|
|
from modules.conf import create_dir_top
|
|
from modules.conf import exists_dir_top
|
|
from modules.conf import exists_dir_sub
|
|
from modules.conf import exists_file
|
|
|
|
# import modules.conf as conf
|
|
|
|
|
|
@task
|
|
def test(*args, **kwargs):
|
|
"""
|
|
Test functions in conf
|
|
|
|
Keyword Arguments:
|
|
|
|
funcname -- name of testing function to run
|
|
"""
|
|
# configuration = env.config
|
|
|
|
# dictionary of legitimate functions that can be tested
|
|
# when given the param name
|
|
test_values = {
|
|
'conf_top': test_conf_top,
|
|
'conf_sub': test_conf_sub,
|
|
'conf_file': test_conf_file,
|
|
}
|
|
|
|
funcname = kwargs.get('funcname')
|
|
|
|
if not funcname:
|
|
if len(args) > 0:
|
|
funcname = args[0]
|
|
args = args[1:]
|
|
|
|
if funcname in test_values.keys():
|
|
test_values[funcname](*args, **kwargs)
|
|
|
|
else:
|
|
print "\nTest functions in this module, acceptable values include:"
|
|
for val in test_values:
|
|
print val
|
|
|
|
|
|
def test_conf_file(*args, **kwargs):
|
|
SPACING = "\n"
|
|
utils.print_console("testing exist_conf_file",
|
|
prepend=SPACING, append=SPACING)
|
|
|
|
confargument = kwargs.get('conf')
|
|
if not confargument:
|
|
confargument = args[0] if len(args) > 0 else None
|
|
|
|
exists_file(confargument)
|
|
|
|
|
|
def test_conf_sub(*args, **kwargs):
|
|
SPACING = "\n"
|
|
utils.print_console("testing exist_conf_sub",
|
|
prepend=SPACING, append=SPACING)
|
|
|
|
confargument = kwargs.get('conf')
|
|
if not confargument:
|
|
confargument = args[0] if len(args) > 0 else None
|
|
|
|
exists_dir_sub(confargument)
|
|
|
|
|
|
def test_conf_top(*args, **kwargs):
|
|
configuration = env.config
|
|
SPACING = "\n"
|
|
|
|
utils.print_console("testing exists_conf",
|
|
prepend=SPACING, append=SPACING)
|
|
|
|
utils.printvar("exists_dir_top",
|
|
exists_dir_top())
|
|
|
|
utils.print_console("testing create_dir_top",
|
|
prepend=SPACING, append=SPACING)
|
|
|
|
if exists_dir_top():
|
|
|
|
msg = "conf directory already exists, move conf to a temporary " \
|
|
"directory, and test out the create_dir_top function."
|
|
utils.print_console(msg, prepend=SPACING, append=SPACING, sep=None)
|
|
|
|
#
|
|
# command to create a temporary directory and echo it's name
|
|
# back to stdout, so we can store that name for use
|
|
|
|
cmd_mktmp = "mytmpdir=`mktemp -d 2>/dev/null ||" \
|
|
" mktemp -d -t 'mytmpdir'`"
|
|
cmd_mktmp = cmd_mktmp + "; echo $mytmpdir"
|
|
|
|
#
|
|
# create a temporary diretory to store old conf files
|
|
|
|
tmpdir = run(cmd_mktmp)
|
|
|
|
#
|
|
# make sure we are working with a legit path
|
|
# otherwise, just kick out.
|
|
|
|
with utils.virtualenv():
|
|
cmd_py_isdir = "python -c \"import os; "\
|
|
"print os.path.isdir('%s')\"" % \
|
|
configuration.paths.conf.remote
|
|
|
|
#
|
|
# take the output from this command and booleanize it
|
|
|
|
output = run(cmd_py_isdir)
|
|
is_dir = utils.booleanize(output)
|
|
utils.printvar("is_dir", is_dir)
|
|
|
|
if is_dir:
|
|
lastpart = os.path.basename(configuration.paths.conf.remote)
|
|
|
|
path_conf_tmp = os.path.join(tmpdir, lastpart)
|
|
else:
|
|
|
|
utils.printvar("configuration.paths.conf.remote",
|
|
configuration.paths.conf.remote)
|
|
|
|
msg = "the original configuration path is NOT a path." \
|
|
"Continue? y/N"
|
|
|
|
utils.prompt_continue(message=msg, default="N")
|
|
|
|
#
|
|
# now move the original configuration directory to the temporary
|
|
# location, and run test running create_dir_top on an empty
|
|
|
|
msg = "moving original conf directory."
|
|
utils.print_console(msg, prepend=SPACING, append=SPACING, sep=None)
|
|
|
|
cmd_mvtmp = "mv %s %s" % \
|
|
(configuration.paths.conf.remote, path_conf_tmp)
|
|
|
|
run(cmd_mvtmp)
|
|
|
|
#
|
|
# create the new conf directory
|
|
|
|
msg = "creating new conf directory."
|
|
utils.print_console(msg, prepend=SPACING, append=SPACING, sep=None)
|
|
create_dir_top()
|
|
|
|
#
|
|
# testing on empty location completed, remove the current directory
|
|
# and move back the original
|
|
|
|
msg = "removing created directory."
|
|
utils.print_console(msg, prepend=SPACING, append=SPACING, sep=None)
|
|
|
|
cmd_rm_created = "rm -Rf %s" % configuration.paths.conf.remote
|
|
run(cmd_rm_created)
|
|
|
|
#
|
|
# returning original directory
|
|
|
|
msg = "Moving back original directory."
|
|
utils.print_console(msg, prepend=SPACING, append=SPACING, sep=None)
|
|
|
|
cmd_return_orig = "mv %s %s" % \
|
|
(path_conf_tmp, configuration.paths.conf.remote)
|
|
|
|
run(cmd_return_orig)
|
|
|
|
cmd_rmtmp = "rm -Rf %s" % tmpdir
|
|
run(cmd_rmtmp)
|
|
else:
|
|
msg = "conf directory does not exist, test out create_dir_top"
|
|
utils.print_console(msg, prepend=SPACING, append=SPACING, sep=None)
|
|
|
|
create_dir_top()
|