Did I find the right examples for you? yes no

All Samples(22)  |  Call(12)  |  Derive(0)  |  Import(10)
Render and upload a template text file to a remote host.

``filename`` should be the path to a text file, which may contain `Python
string interpolation formatting
<http://docs.python.org/release/2.5.4/lib/typesseq-strings.html>`_ and will
be rendered with the given context dictionary ``context`` (if given.)

Alternately, if ``use_jinja`` is set to True and you have the Jinja2
templating library available, Jinja will be used to render the template
instead. Templates will be loaded from the invoking user's current working(more...)

        def upload_template(filename, destination, context=None, use_jinja=False,
    template_dir=None, use_sudo=False, backup=True, mirror_local_mode=False,
    mode=None):
    """
    Render and upload a template text file to a remote host.

    ``filename`` should be the path to a text file, which may contain `Python
    string interpolation formatting
    `_ and will
    be rendered with the given context dictionary ``context`` (if given.)

    Alternately, if ``use_jinja`` is set to True and you have the Jinja2
    templating library available, Jinja will be used to render the template
    instead. Templates will be loaded from the invoking user's current working
    directory by default, or from ``template_dir`` if given.

    The resulting rendered file will be uploaded to the remote file path
    ``destination``.  If the destination file already exists, it will be
    renamed with a ``.bak`` extension unless ``backup=False`` is specified.

    By default, the file will be copied to ``destination`` as the logged-in
    user; specify ``use_sudo=True`` to use `sudo` instead.

    The ``mirror_local_mode`` and ``mode`` kwargs are passed directly to an
    internal `~fabric.operations.put` call; please see its documentation for
    details on these two options.

    .. versionchanged:: 1.1
        Added the ``backup``, ``mirror_local_mode`` and ``mode`` kwargs.
    """
    func = use_sudo and sudo or run
    # Normalize destination to be an actual filename, due to using StringIO
    with settings(hide('everything'), warn_only=True):
        if func('test -d %s' % destination).succeeded:
            sep = "" if destination.endswith('/') else "/"
            destination += sep + os.path.basename(filename)

    # Use mode kwarg to implement mirror_local_mode, again due to using
    # StringIO
    if mirror_local_mode and mode is None:
        mode = os.stat(filename).st_mode
        # To prevent put() from trying to do this
        # logic itself
        mirror_local_mode = False

    # Process template
    text = render_template(filename, context=context,
                           use_jinja=use_jinja,
                           template_dir=template_dir)

    # Back up original file
    if backup and exists(destination):
        func("cp %s{,.bak}" % destination)

    # Upload the file.
    put(
        local_path=StringIO(text),
        remote_path=destination,
        use_sudo=use_sudo,
        mirror_local_mode=mirror_local_mode,
        mode=mode
    )
        


src/s/p/speedydeploy-HEAD/speedydeploy/project/sphinxsearch.py   speedydeploy(Download)
from ..base import _, Daemon, Debian, RedHat
from ..deployment import command
from ..utils import upload_template, upload_first
 
 
    def configure_daemon(self):
        upload_template('sphinxsearch/searchd',
                        _("/etc/init.d/%(project_name)s_searchd"),
                        context=fab.env,
                        use_sudo=True,
    def put_config(self):
        if not self.supervisor:
            self.configure_daemon()
 
        upload_template("sphinxsearch/sphinx.conf",
                        _("%(remote_dir)s/etc/sphinxsearch/sphinx.conf"),
                        fab.env,
                        use_jinja=True)
 
        upload_template("sphinxsearch/index_all.sh",
                        )
 
        upload_template("sphinxsearch/index_delta.sh",
                        _("%(remote_dir)s/etc/sphinxsearch/index_delta.sh"),
                        fab.env,

src/s/p/speedydeploy-HEAD/speedydeploy/project/celery.py   speedydeploy(Download)
from ..base import _, Daemon
from ..deployment import command
from ..utils import upload_template, upload_first
 
from cron import CronTab
    def configure_daemon(self):
        upload_template('celery/celeryd',
                        _("/etc/init.d/%(project_name)s_celeryd"),
                        context=fab.env,
                        use_jinja=True,
    def put_config(self):
        if not self.supervisor:
            self.configure_daemon()
 
        upload_template('celery/celeryd.conf',

src/s/p/speedydeploy-HEAD/speedydeploy/deployment.py   speedydeploy(Download)
 
from base import _, OS, Debian, Ubuntu, Ubuntu104, Daemon, CommandNamespace
from utils import upload_template, upload_first
 
 
    def sudo_configure(self):
        upload_template('sudoers/speedydeploy',
                        '/etc/sudoers.d/speedydeploy',
                        fab.env,
                        use_sudo=True,

src/s/p/speedydeploy-HEAD/speedydeploy/project/__init__.py   speedydeploy(Download)
from ..base import _, Daemon, Debian, RedHat, Ubuntu
from ..deployment import command
from ..utils import upload_template, upload_first
 
from celery import RabbitMQ, Celery
    def add_script(self, file_name, remote_name=None):
 
        remote_name = remote_name or _('%(user)s')
 
        upload_template(file_name,

src/s/p/speedydeploy-HEAD/speedydeploy/webserver.py   speedydeploy(Download)
from base import _, Daemon, Ubuntu
from deployment import command
from utils import upload_template, upload_first
 
 
    def configure(self):
        upload_template(_('apache/%(domain)s.conf'),
                        fab.env.os.path.join(self.sites_dir,
                                             _('%(domain)s.conf') ),
                        fab.env,

src/s/p/speedydeploy-HEAD/speedydeploy/project/supervisor.py   speedydeploy(Download)
from ..base import _, Daemon
from ..deployment import command
from ..utils import upload_template, upload_first
 
 
    def configure(self):
        self.install_development_libraries()
 
        upload_template(_('supervisor/supervisord.conf'),
                        '/etc/supervisor/supervisord.conf',

src/s/p/speedydeploy-HEAD/speedydeploy/project/django.py   speedydeploy(Download)
 
from ..base import _
from ..utils import render_template, upload_template
from ..deployment import command
 
                context['settings_%s' % name] = ''
 
        upload_template(self.settings_local,
                        settings_local_path,
                        context, use_jinja=True)

src/s/p/speedydeploy-HEAD/speedydeploy/project/memcache.py   speedydeploy(Download)
from ..base import _, Daemon, Ubuntu
from ..deployment import command
from ..utils import upload_template, upload_first
 
 
    def put_config(self):
 
        upload_template('memcached/memcached.conf',
                        _("%(remote_dir)s/etc/memcached.conf"),
                        use_jinja=True)

src/s/p/speedydeploy-HEAD/speedydeploy/project/redis.py   speedydeploy(Download)
from ..base import _, Daemon, Ubuntu
from ..deployment import command
from ..utils import upload_template, upload_first
 
 

src/s/p/speedydeploy-HEAD/speedydeploy/project/cron.py   speedydeploy(Download)
from ..base import _, Daemon
from ..deployment import command
from ..utils import upload_template, upload_first