当前位置: 首页>>代码示例>>Python>>正文


Python app.app_context方法代码示例

本文整理汇总了Python中app.app.app_context方法的典型用法代码示例。如果您正苦于以下问题:Python app.app_context方法的具体用法?Python app.app_context怎么用?Python app.app_context使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app.app的用法示例。


在下文中一共展示了app.app_context方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: perform

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import app_context [as 别名]
def perform(self, notification_obj, event_handler, notification_data):
        config_data = notification_obj.method_config_dict
        email = config_data.get("email", "")
        if not email:
            return

        with app.app_context():
            msg = Message(
                event_handler.get_summary(notification_data["event_data"], notification_data),
                recipients=[email],
            )
            msg.html = event_handler.get_message(notification_data["event_data"], notification_data)

            try:
                mail.send(msg)
            except Exception as ex:
                logger.exception("Email was unable to be sent")
                raise NotificationMethodPerformException(str(ex)) 
开发者ID:quay,项目名称:quay,代码行数:20,代码来源:notificationmethod.py

示例2: sendInvoice

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import app_context [as 别名]
def sendInvoice(invoice_id):
    invoice = stripe.Invoice.retrieve(invoice_id)
    if not invoice["customer"]:
        print("No customer found")
        return

    customer_id = invoice["customer"]
    user = model.user.get_user_or_org_by_customer_id(customer_id)
    if not user:
        print("No user found for customer %s" % (customer_id))
        return

    with app.app_context():
        file_data = renderInvoiceToPdf(invoice, user)
        with open("invoice.pdf", "wb") as f:
            f.write(file_data)

        print("Invoice output as invoice.pdf") 
开发者ID:quay,项目名称:quay,代码行数:20,代码来源:renderinvoice.py

示例3: sendInvoice

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import app_context [as 别名]
def sendInvoice(invoice_id):
    invoice = stripe.Invoice.retrieve(invoice_id)
    if not invoice["customer"]:
        print("No customer found")
        return

    customer_id = invoice["customer"]
    user = model.user.get_user_or_org_by_customer_id(customer_id)
    if not user:
        print("No user found for customer %s" % (customer_id))
        return

    with app.app_context():
        invoice_html = renderInvoiceToHtml(invoice, user)
        send_invoice_email(user.invoice_email_address or user.email, invoice_html)
        print("Invoice sent to %s" % (user.invoice_email_address or user.email)) 
开发者ID:quay,项目名称:quay,代码行数:18,代码来源:emailinvoice.py

示例4: flask_app

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import app_context [as 别名]
def flask_app():
    """Set up the application context for testing."""
    ctx = app.app_context()
    ctx.push()
    yield app
    ctx.pop() 
开发者ID:ColtonProvias,项目名称:sqlalchemy-jsonapi,代码行数:8,代码来源:conftest.py

示例5: sendConfirmation

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import app_context [as 别名]
def sendConfirmation(username):
    user = model.user.get_nonrobot_user(username)
    if not user:
        print("No user found")
        return

    with app.app_context():
        confirmation_code = model.user.create_confirm_email_code(user)
        send_confirmation_email(user.username, user.email, confirmation_code)
        print("Email sent to %s" % (user.email)) 
开发者ID:quay,项目名称:quay,代码行数:12,代码来源:sendconfirmemail.py

示例6: sendReset

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import app_context [as 别名]
def sendReset(username):
    user = model.user.get_nonrobot_user(username)
    if not user:
        print("No user found")
        return

    with app.app_context():
        confirmation_code = model.user.create_reset_password_email_code(user.email)
        send_recovery_email(user.email, confirmation_code)
        print("Email sent to %s" % (user.email)) 
开发者ID:quay,项目名称:quay,代码行数:12,代码来源:sendresetemail.py

示例7: main

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import app_context [as 别名]
def main():
    with app.app_context():
        db.create_all() 
开发者ID:duo-labs,项目名称:py_webauthn,代码行数:5,代码来源:create_db.py

示例8: send_async

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import app_context [as 别名]
def send_async(app, message):
    ''' Send the mail asynchronously. '''
    with app.app_context():
        mail.send(message) 
开发者ID:MaxHalford,项目名称:flask-boilerplate,代码行数:6,代码来源:email.py

示例9: exposed_fetch_unmapped_qidian_items

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import app_context [as 别名]
def exposed_fetch_unmapped_qidian_items():
	'''
	'''
	from app import app
	from flask import g

	# with app.app_context():
	with app.test_request_context(""):
		app.preprocess_request()

		print("Querying for rss feed items.")
		# Hard coded for my database. Because fuk u \
		releases = g.session.query(db.RssFeedPost)   \
			.filter(db.RssFeedPost.feed_id == 2578)   \
			.all()

		print("Processing items")
		urls = [item.contenturl for item in releases]

		relmap = {}
		for release in releases:
			if "/rssbook/" in release.contenturl:
				continue
			trimmed = "/".join(release.contenturl.split("/")[:5])+"/"
			relmap.setdefault(trimmed, [])
			relmap[trimmed].append(release)

		print("Fetched %s urls, %s distinct series" % (len(urls), len(relmap)))

		for itemlist in relmap.values():
			itemlist.sort(key=lambda x: x.id)

		truncated_releases = [tmp[0] for tmp in relmap.values()]

		print("Truncated releases: %s" % len(truncated_releases))

		items = proto_process_releases(truncated_releases)
		print("Processing resulted in %s feed items" % len(items['missed']))

		feed_urls = [tmp[1]['linkUrl'] for tmp in items['missed']]
		trimmed = ["/".join(tmp.split("/")[:5])+"/" for tmp in feed_urls]

		new_series_urls = list(set(trimmed))
		print("Releases consolidated to %s distinct series" % len(new_series_urls))

	bad_names = [
		'12testett11223355',
		'webnovel test003',
		'www.webnovel.com',
	]
	wg = WebRequest.WebGetRobust()
	for url in new_series_urls:
		meta = common.management.util.get_page_title(wg, url)
		if not any([tmp in meta['title'] for tmp in bad_names]):
			print('Missing: "%s" %s: "%s",' % (url, " " * (50 - len(url)), meta))
			itemid = url.split("/")
			itemid = [tmp for tmp in itemid if tmp]
			itemid = itemid[-1]
			print("'%s' : ('%s',                                                                     '%s')," % (itemid, meta['title'].strip(), 'oel' if 'is-orig' in meta and meta['is-orig'] else 'translated')) 
开发者ID:fake-name,项目名称:ReadableWebProxy,代码行数:61,代码来源:RssManage.py


注:本文中的app.app.app_context方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。