Contenu connexe
Similaire à Donetsk.py - fabric (20)
Donetsk.py - fabric
- 2. About
Fabric is a Python library and command-line
tool for streamlining the use of SSH for
application deployment or systems
administration tasks.
- 3. Features
• Executing local or remote shell commands
(normally or via sudo)
• Processing output
• Uploading/downloading files
• Prompting for input, aborting execution, etc
• Multiple host, flexible configuration
- 6. env vs settings
from fabric.api import settings, run, env
env.hosts = ['example.com']
def exists(path):
with settings(warn_only=True):
return run('test -e %s' % path)
$ fab exists:/home
$ fab exists:/home,host=‘example.net’
- 8. Context Managers
• cd/lcd
• path/prefix
• settings
with prefix('workon myenv'):
run('ls')
with prefix('source /some/script'):
run('touch a_file')
$ workon myenv && ls
$ workon myenv && source /some/script && touch a_file
Notes de l'éditeur
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n