简体   繁体   English

对现有文件夹进行面料检查并制作新文件夹

[英]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.

相关问题 写入新文件夹或现有文件夹 - Writing to a New or Existing Folder 检查现有进程是否存在 - 如果存在,则与其通信,否则创建一个新进程 - Check if existing process exists - if it does, communicate with it, otherwise create a new one 架构检查用户对文件/文件夹具有权限 - Fabric check user has permissions on file/folder 如何使用StackedInline类将现有模型对象设为只读,但又能够创建一个新模型对象? - How to make existing model objects read-only but also be able to create a new one, using StackedInline class? 从现有数据框中创建新数据框,其中一列中的唯一值和其他列中的对应值 - Make new dataframe from existing dataframe with unique values from one column and corresponding values from other columns 检查文件夹图像的扩展类型并确保所有图像都是一种格式 - Check folder's image's extension type and make sure all images are of one format 如何检查python文件夹中的新文件 - How to check for new files in a folder in python 如何检查复制到特定文件夹的新文件? - How to check for new files that are copied to a specific folder? 从现有数据框列创建新数据框 - Make new dataframe from existing dataframe columns 通过更新现有字典来创建新字典 - Creating a new dict by updating an existing one
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM