def wrapper(event, context): log = get_logger(__name__) log.info(event) try: result = func(event, context) except Exception as e: log.exception(e) raise e return result
def wrapper(event, context): ret = [] log = get_logger(__name__) for record in event['Records']: message = json.loads(record['Sns']['Message']) log.info(event) try: result = func(message, context) except Exception as e: log.exception(e) raise e return result
from qp import deco from qp.error import QpError from qp.libs.qiita import create_qiita from qp.libs.template import render_template from qp.libs.renderconfig import ( find_render_config_by_article, get_publish_status, put_published_status ) from qp import settings from qp.logs import get_logger log = get_logger(__name__) @deco.from_sfn def find_template_by_article(data, context={}): """記事のレンダリングに使用するパラメータを返す :param data: {article<str>} :type data: [type] :param context: defaults to {} :type context: dict, optional :return: {article<str>, template_name<str>, template_variables<dict>} :rtype: dict """ return find_render_config_by_article(data['article']) @deco.from_sfn
import json import boto3 from qp import settings from qp import logs log = logs.get_logger(__name__) client = None def _get_client(): global client if client is None: client = boto3.client('stepfunctions') return client def _get_state_machine_name(name): return 'arn:aws:states:{}:{}:stateMachine:{}'.format( settings.AWS_REGION, settings.AWS_ACCOUNT_ID, name ) def start_execution(name, params): return _get_client().start_execution( stateMachineArn=_get_state_machine_name(name), input=params )