scar.py 文件源码

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

项目:scar 作者: grycap 项目源码 文件源码
def create_zip_file(self, file_name, args):
        # Set generic lambda function name
        function_name = file_name + '.py'
        # Copy file to avoid messing with the repo files
        # We have to rename because the function name afects the handler name
        shutil.copy(Config.dir_path + '/lambda/scarsupervisor.py', function_name)
        # Zip the function file
        with zipfile.ZipFile(Config.zip_file_path, 'w', zipfile.ZIP_DEFLATED) as zf:
            # Lambda function code
            zf.write(function_name)
            # Udocker script code
            zf.write(Config.dir_path + '/lambda/udocker', 'udocker')
            # Udocker libs
            zf.write(Config.dir_path + '/lambda/udocker-1.1.0-RC2.tar.gz', 'udocker-1.1.0-RC2.tar.gz')
            os.remove(function_name)
            if hasattr(args, 'script') and args.script:
                zf.write(args.script, 'init_script.sh')
                Config.lambda_env_variables['Variables']['INIT_SCRIPT_PATH'] = "/var/task/init_script.sh"
        if hasattr(args, 'extra_payload') and args.extra_payload:
            self.zipfolder(Config.zip_file_path, args.extra_payload)
            Config.lambda_env_variables['Variables']['EXTRA_PAYLOAD'] = "/var/task/extra/"
        # Return the zip as an array of bytes
        with open(Config.zip_file_path, 'rb') as f:
            return f.read()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号