??????б???????
??????????????:
from fabric.api import local
def lsfab():
local('cd ~/tmp/fab')
local('ls')
?????????
[ken@~/tmp/fab$] pwd;ls
/Users/ken/tmp/fab
fabfile.py   fabfile.pyc  test.py      test.pyc
[ken@~/tmp/fab$] fab -f test.py lsfab
[localhost] local: cd ~/tmp/fab
[localhost] local: ls
fabfile.py  fabfile.pyc test.py     test.pyc
Done.
???????????
???????裬??????????????????settings.py???汾????????п????????????
??????????????????
????cd /home/project/test/conf/
????git add settings.py
????git commit -m 'daily update settings.py'
????git pull origin
????git push origin
???????????????????????????????Σ???νdaily job????????????????е????????????????????fabric?????????????(?????shell?????????????????fab??????????????????????λ???汾??+????????????????????????????д????????????)
????from fabric.api import local
????def setting_ci():
????local("cd /home/project/test/conf/")
????local("git add settings.py")
????#?????????????????…..
?????????????????
????????????裬?????????A??/home/ken/project?????????????????????????
#!/usr/bin/env python
# encoding: utf-8
from fabric.api import local??cd??run
env.hosts=['user@ip:port'??] #ssh?????????
env.password = 'pwd'
def setting_ci():
local('echo "add and commit settings in local"')
#???????????????????
def update_setting_remote():
print "remote update"
with cd('~/temp'):   #cd????????????
run('ls -l | wc -l')  #????????run
def update():
setting_ci()
update_setting_remote()
?????????????
[ken@~/tmp/fab$] fab -f deploy.py update
[user@ip:port] Executing task 'update'
[localhost] local: echo "add and commit settings in local"
add and commit settings in local
remote update
[user@ip:port] run: ls -l | wc -l
[user@ip:port] out: 12
[user@ip:port] out:
Done.
????????????????env.password????е??????????????????????????????