cli.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:tight-cli 作者: Lululemon 项目源码 文件源码
def artifact(*args, **kwargs):
    """
    Generate an artifact for the app. Will be located at ./build

    :param args:
    :param kwargs:
    :return:
    """
    target = kwargs.pop('target')
    name = get_config(target)['name']
    zip_name = '{}/builds/{}-artifact-{}'.format(target, name, int(time.time()))
    builds_dir = '{}/builds'.format(target)
    if os.path.exists(builds_dir):
        shutil.rmtree(builds_dir)

    os.mkdir(builds_dir)
    os.mkdir('{}/{}-artifact'.format(builds_dir, name))

    directory_list = ['{}/app'.format(target)]
    file_list = ['{}/app_index.py'.format(target), '{}/env.dist.yml'.format(target), '{}/tight.yml'.format(target)]

    create_zip = ['zip', '-9', zip_name]
    subprocess.call(create_zip)
    artifact_dir = '{}/builds/{}-artifact/'.format(target, name)

    for dir in directory_list:
        cp_dir_command = ['cp', '-R', dir, artifact_dir]
        subprocess.call(cp_dir_command)

    for file_name in file_list:
        cp_file_command = ['cp', file_name, artifact_dir]
        subprocess.call(cp_file_command)

    shutil.make_archive(zip_name, 'zip', root_dir=artifact_dir)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号