added example of context manager use
This commit is contained in:
parent
501ef7e35c
commit
8881f50ffb
17
context_managers.py
Normal file
17
context_managers.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
from fabric.api import env, run, cd, settings, local
|
||||||
|
|
||||||
|
env.roledefs = {
|
||||||
|
'web': ['web1', 'web2', 'web3'],
|
||||||
|
'db': ['db1', 'db2']
|
||||||
|
}
|
||||||
|
|
||||||
|
def cd_example():
|
||||||
|
with cd('/tmp'):
|
||||||
|
run('pwd')
|
||||||
|
|
||||||
|
|
||||||
|
def push_anyway():
|
||||||
|
with settings(warn_only=True):
|
||||||
|
# simulate failure
|
||||||
|
local('false')
|
||||||
|
run('echo doing it anyway')
|
Loading…
Reference in New Issue
Block a user