fabtools.require.files

Files and directories

This module provides high-level tools for managing files and directories.

See also

fabtools.files

fabtools.require.files.directory(path, use_sudo=False, owner='', group='', mode='')[source]

Require a directory to exist.

from fabtools import require

require.directory('/tmp/mydir', owner='alice', use_sudo=True)

Note

This function can be accessed directly from the fabtools.require module for convenience.

fabtools.require.files.file(path=None, contents=None, source=None, url=None, md5=None, use_sudo=False, owner=None, group='', mode=None, verify_remote=True)[source]

Require a file to exist and have specific contents and properties.

You can provide either:

  • contents: the required contents of the file:

    from fabtools import require
    
    require.file('/tmp/hello.txt', contents='Hello, world')
    
  • source: the local path of a file to upload:

    from fabtools import require
    
    require.file('/tmp/hello.txt', source='files/hello.txt')
    
  • url: the URL of a file to download (path is then optional):

    from fabric.api import cd
    from fabtools import require
    
    with cd('tmp'):
        require.file(url='http://example.com/files/hello.txt')
    

If verify_remote is True (the default), then an MD5 comparison will be used to check whether the remote file is the same as the source. If this is False, the file will be assumed to be the same if it is present. This is useful for very large files, where generating an MD5 sum may take a while.

Note

This function can be accessed directly from the fabtools.require module for convenience.

fabtools.require.files.template_file(path=None, template_contents=None, template_source=None, context=None, **kwargs)[source]

Require a file whose contents is defined by a template.

Project Versions

Table Of Contents

Previous topic

fabtools.require.deb

Next topic

fabtools.require.groups

This Page