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.directories(path_list, use_sudo=False, owner='', group='', mode='')[source]

Require a list of directories to exist.

from fabtools import require
dirs=[
    '/tmp/mydir',
    '/tmp/mydear',
    '/tmp/my/dir'
]
require.directories(dirs, owner='alice', mode='750')

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.

Read the Docs v: 0.16.0
Versions
latest
0.16.0
0.15.0
0.14.0
0.13.0
0.12.0
0.11.0
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.