Internal utilities

class dploi_fabric.utils.Configuration[source]

This class is the only correct source of information for this project. To reduce the amount of times config.ini is downloaded, it should always be used from utils.config, which is an instance of Configuration

build_environment_export(environment)[source]

takes a dict with environment variables and products a shell compatible export statement: ‘export PYTHONPATH=”stuff/here:more/here” USER=”mysite-dev”;’

defaults = {'sendfile': {}, 'supervisor': {'group_template': '/home/docs/checkouts/readthedocs.org/user_builds/dploi-fabric/checkouts/latest/dploi_fabric/templates/supervisor/supervisor-group.conf', 'celeryd_command_template': '/home/docs/checkouts/readthedocs.org/user_builds/dploi-fabric/checkouts/latest/dploi_fabric/templates/supervisor/celeryd_command', 'template': '/home/docs/checkouts/readthedocs.org/user_builds/dploi-fabric/checkouts/latest/dploi_fabric/templates/supervisor/supervisor.conf', 'supervisord_command': None, 'celerycam_command_template': '/home/docs/checkouts/readthedocs.org/user_builds/dploi-fabric/checkouts/latest/dploi_fabric/templates/supervisor/celerycam_command', 'use_global_supervisord': False, 'daemon_template': '/home/docs/checkouts/readthedocs.org/user_builds/dploi-fabric/checkouts/latest/dploi_fabric/templates/supervisor/supervisord.conf', 'gunicorn_command_template': '/home/docs/checkouts/readthedocs.org/user_builds/dploi-fabric/checkouts/latest/dploi_fabric/templates/supervisor/gunicorn_command', 'supervisorctl_command': None}, 'gunicorn': {'bind': None, 'workers': 2, 'maxrequests': 0, 'version': None, 'timeout': None}, 'nginx': {'client_max_body_size': '10m', 'enabled': True, 'template': '/home/docs/checkouts/readthedocs.org/user_builds/dploi-fabric/checkouts/latest/dploi_fabric/templates/nginx/nginx.conf'}, 'static': {}, 'newrelic': {'config_file': 'newrelic.ini', 'environment_name': '', 'enabled': False, 'license': ''}, 'environment': {}, 'processes': {}, 'checkout': {'tool': 'buildout'}, 'redis': {'appendonly': 'no', 'enabled': False, 'template': '/home/docs/checkouts/readthedocs.org/user_builds/dploi-fabric/checkouts/latest/dploi_fabric/templates/redis/redis.conf'}, 'django': {'cmd': 'bin/django', 'base': '.', 'args': [], 'append_settings': False}, 'celery': {'extra_options': '', 'celerycam': False, 'version': None, 'celerybeat': True, 'celerycam-frequency': 1.0, 'concurrency': 1, 'loglevel': 'WARNING', 'app': 'project', 'enabled': False, 'maxtasksperchild': 500}, 'logdir': None, 'memcached': {'enabled': True, 'size': 64}}

Default values for the configuration

deployment(site, env_dict)[source]

Here we add the information from deployments.py and merge it into our site dictionaries. Can also be used to output warnings to the user, if he is using an old deployments.py format.

django_manage(command, site='main')[source]

Wrapper around the commands to inject the correct pythonpath.

Example: django_manage(“migrate”), could result in

export PYTONPATH=/home/app-dev/app/; /home/app-dev/app/bin/python /home/app-dev/app/manage.py migrate

load_sites(config_file_content=None, env_dict=None)[source]

Called from self.sites and returns a dictionary with the different sites and their individual settings.

processes(site, env_dict)[source]

Returns a dictionary of dictionaries each having the following keys:

  • command

    command to be run by supervisor

  • port

    port number,

  • socket

    path to unix socket

  • type

    gunicorn/memcached/celeryd