本文整理汇总了Python中beeswax.models.QueryHistory.log_context方法的典型用法代码示例。如果您正苦于以下问题:Python QueryHistory.log_context方法的具体用法?Python QueryHistory.log_context怎么用?Python QueryHistory.log_context使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类beeswax.models.QueryHistory
的用法示例。
在下文中一共展示了QueryHistory.log_context方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute_directly
# 需要导入模块: from beeswax.models import QueryHistory [as 别名]
# 或者: from beeswax.models.QueryHistory import log_context [as 别名]
def execute_directly(user, query_msg, design=None, notify=False):
"""
execute_directly(user, query_msg [,design]) -> QueryHistory object
This method also creates a QueryHistory object and saves it.
user - Django user.
query_msg - The thrift Query object.
design - The SavedQuery object (i.e. design) associated with this query.
notify - Whether to notify the user upon completion.
"""
query_history = QueryHistory(
owner=user,
query=query_msg.query,
last_state=QueryHistory.STATE.submitted.index,
design=design,
notify=notify)
query_history.save()
LOG.debug("Made new QueryHistory id %s user %s query: %s..." %
(query_history.id, user, query_history.query[:25]))
# Now submit it
try:
handle = db_client().query(query_msg)
if not handle or not handle.id or not handle.log_context:
# It really shouldn't happen
msg = "BeeswaxServer returning invalid handle for query id %d [%s]..." % \
(query_history.id, query_msg.query[:40])
raise Exception(msg)
except BeeswaxException, bex:
# Kind of expected (hql compile/syntax error, etc.)
if bex.handle:
query_history.server_id = bex.handle.id
query_history.log_context = bex.handle.log_context
query_history.save_state(QueryHistory.STATE.failed)
raise bex
示例2: execute_directly
# 需要导入模块: from beeswax.models import QueryHistory [as 别名]
# 或者: from beeswax.models.QueryHistory import log_context [as 别名]
def execute_directly(user, query_msg, query_server=None, design=None, notify=False):
"""
execute_directly(user, query_msg [,design]) -> QueryHistory object
This method also creates a QueryHistory object and saves it.
user - Django user.
query_msg - The thrift Query object.
design - The SavedQuery object (i.e. design) associated with this query.
notify - Whether to notify the user upon completion.
"""
if query_server is None:
query_server = get_query_server(support_ddl=True) # For convenience with DDL queries only
query_history = QueryHistory(
owner=user,
query=query_msg.query,
server_host='%(server_host)s' % query_server,
server_port='%(server_port)d' % query_server,
server_name='%(server_name)s' % query_server,
last_state=QueryHistory.STATE.submitted.index,
design=design,
notify=notify)
query_history.save()
LOG.debug("Made new QueryHistory id %s user %s query: %s..." %
(query_history.id, user, query_history.query[:25]))
# Now submit it
try:
handle = db_client(query_server).query(query_msg)
if not handle or not handle.id:
# It really shouldn't happen
msg = _("BeeswaxServer returning invalid handle for query id %(id)d [%(query)s]...") % \
{'id': query_history.id, 'query': query_msg.query[:40]}
raise Exception(msg)
except BeeswaxException, bex:
# Kind of expected (hql compile/syntax error, etc.)
if bex.handle:
query_history.server_id = bex.handle.id
query_history.log_context = bex.handle.log_context
query_history.save_state(QueryHistory.STATE.failed)
raise bex