本文整理匯總了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'])