本文整理汇总了Python中c7n.mu.PythonPackageArchive.add_py_file方法的典型用法代码示例。如果您正苦于以下问题:Python PythonPackageArchive.add_py_file方法的具体用法?Python PythonPackageArchive.add_py_file怎么用?Python PythonPackageArchive.add_py_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类c7n.mu.PythonPackageArchive
的用法示例。
在下文中一共展示了PythonPackageArchive.add_py_file方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_function
# 需要导入模块: from c7n.mu import PythonPackageArchive [as 别名]
# 或者: from c7n.mu.PythonPackageArchive import add_py_file [as 别名]
def get_function(session_factory, name, role, sns_topic, log_groups,
subject="Lambda Error", pattern="Traceback"):
"""Lambda function provisioning.
Self contained within the component, to allow for easier reuse.
"""
# Lazy import to avoid runtime dependency
from c7n.mu import (
LambdaFunction, PythonPackageArchive, CloudWatchLogSubscription)
config = dict(
name=name,
handler='logsub.process_log_event',
runtime='python2.7',
memory_size=512,
timeout=15,
role=role,
description='Custodian Ops Error Notify',
events=[
CloudWatchLogSubscription(
session_factory, log_groups, pattern)])
archive = PythonPackageArchive()
archive.add_py_file(__file__)
archive.add_contents(
'config.json', json.dumps({
'topic': sns_topic,
'subject': subject
}))
archive.close()
return LambdaFunction(config, archive)
示例2: get_function
# 需要导入模块: from c7n.mu import PythonPackageArchive [as 别名]
# 或者: from c7n.mu.PythonPackageArchive import add_py_file [as 别名]
def get_function(session_factory, name, role, events):
from c7n.mu import (LambdaFunction, PythonPackageArchive)
config = dict(
name=name,
handler='helloworld.main',
runtime='python2.7',
memory_size=512,
timeout=15,
role=role,
description='Hello World',
events=events)
archive = PythonPackageArchive()
archive.add_py_file(__file__)
archive.close()
return LambdaFunction(config, archive)
示例3: test_reverts_to_py_if_available
# 需要导入模块: from c7n.mu import PythonPackageArchive [as 别名]
# 或者: from c7n.mu.PythonPackageArchive import add_py_file [as 别名]
def test_reverts_to_py_if_available(self):
archive = PythonPackageArchive()
py = self.py_with_pyc('foo.py')
archive.add_py_file(py+'c')
archive.close()
self.assertEqual(archive.get_filenames(), ['foo.py'])
示例4: test_can_add_py_file
# 需要导入模块: from c7n.mu import PythonPackageArchive [as 别名]
# 或者: from c7n.mu.PythonPackageArchive import add_py_file [as 别名]
def test_can_add_py_file(self):
archive = PythonPackageArchive()
archive.add_py_file(self.py_with_pyc('foo.py'))
archive.close()
self.assertEqual(archive.get_filenames(), ['foo.py'])