This module provides high-level tools for managing files and directories.
See also
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.
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.
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.