本文整理汇总了Python中rogerthat.rpc.models.Mobile.get_by_key_name方法的典型用法代码示例。如果您正苦于以下问题:Python Mobile.get_by_key_name方法的具体用法?Python Mobile.get_by_key_name怎么用?Python Mobile.get_by_key_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rogerthat.rpc.models.Mobile
的用法示例。
在下文中一共展示了Mobile.get_by_key_name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _send_notification_about_failed_location_fix
# 需要导入模块: from rogerthat.rpc.models import Mobile [as 别名]
# 或者: from rogerthat.rpc.models.Mobile import get_by_key_name [as 别名]
def _send_notification_about_failed_location_fix(user, friend, friend_mobile_key_name, target, error_status):
'''
@param user: The user who sent the location request.
@param friend: The user who failed to execute the location request.
@param friend_mobile_key_name: The key name of the friend's Mobile model.
@param target: The reason of the location request. One of GetLocationRequestTO.TARGET_*.
@param error_status: The reason of the failed location request. One of GetLocationErrorTO.STATUS_*.
'''
friend_profile, user_profile = get_profile_infos([friend, user], expected_types=[UserProfile, UserProfile])
app_name = get_app_name_by_id(user_profile.app_id)
friend_msg = None
user_reason_msg = None
if error_status in (GetLocationErrorTO.STATUS_AUTHORIZATION_DENIED,
GetLocationErrorTO.STATUS_AUTHORIZATION_ONLY_WHEN_IN_USE):
if error_status == GetLocationErrorTO.STATUS_AUTHORIZATION_DENIED:
friend_msg = localize(friend_profile.language, "_location_services_denied",
name=user_profile.name, app_name=app_name)
user_reason_msg = localize(user_profile.language, "_friend_denied_location_services",
name=friend_profile.name, app_name=app_name)
elif error_status == GetLocationErrorTO.STATUS_AUTHORIZATION_ONLY_WHEN_IN_USE:
friend_msg = localize(friend_profile.language, "_location_services_denied",
name=user_profile.name, app_name=app_name)
user_reason_msg = localize(user_profile.language, "_friend_denied_location_services",
name=friend_profile.name, app_name=app_name)
if friend_msg:
friend_mobile = Mobile.get_by_key_name(friend_mobile_key_name)
if friend_mobile.is_ios and friend_mobile.osVersion:
if friend_mobile.osVersion.startswith('7'):
friend_msg += "\n\n" + localize(friend_profile.language, "_enable_location_services_ios7",
app_name=app_name)
elif friend_mobile.osVersion.startswith('8'):
friend_msg += "\n\n" + localize(friend_profile.language, "_enable_location_services_ios8",
app_name=app_name)
if target == GetLocationRequestTO.TARGET_MOBILE:
user_msg = localize(user_profile.language,
"We could not determine the location of %(name)s.",
name=friend_profile.name)
elif target == GetLocationRequestTO.TARGET_MOBILE_FIRST_REQUEST_AFTER_GRANT:
user_msg = localize(user_profile.language,
"%(name)s accepted your location sharing request. Unfortunately we could not determine his/her location at this moment.",
name=friend_profile.name)
else:
logging.error("Don't know what to do in _send_notification_about_failed_location_fix.\n\nLocals:\n%s" % locals())
return
if user_reason_msg:
user_msg = u"%s (%s)" % (user_msg, user_reason_msg)
if user_msg and not friend_msg:
user_msg = u"%s\n\n%s" % (user_msg, localize(user_profile.language, "Please try again later."))
xg_on = db.create_transaction_options(xg=True)
db.run_in_transaction_options(xg_on, dashboardNotification, user, user_msg)
if friend_msg:
db.run_in_transaction_options(xg_on, dashboardNotification, friend, friend_msg)
示例2: get_mobile_by_account
# 需要导入模块: from rogerthat.rpc.models import Mobile [as 别名]
# 或者: from rogerthat.rpc.models.Mobile import get_by_key_name [as 别名]
def get_mobile_by_account(account):
return Mobile.get_by_key_name(account)