[英]fabric check of existing folder and make new one
In my fabfile.py I am making a directory: 在我的fabfile.py中,我正在建立一个目录:
sudo('mkdir mysite')
I want to check if this site exists then I want to move it to mysite_bkup
and create mysite
我想检查该站点是否存在,然后将其移至
mysite_bkup
并创建mysite
env.path = '/var/www/html/{}'.format(env['project_name'])
if exists(env.path):
sudo("mv %(path)s %(path)s + '_bkup'" % env)
But its giving me error... How can I change the name of it.. 但是它给了我错误...我该如何更改它的名称..
Thank you 谢谢
I did it like this: 我这样做是这样的:
backup = env.path + '_bkup'
print backup
if exists(env.path):
if exists(backup):
sudo('rm -rf {}'.format(backup))
sudo('mv {} {}'.format(env.path, backup))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.