本文整理汇总了Python中rogerthat.rpc.models.Mobile.typeAsString方法的典型用法代码示例。如果您正苦于以下问题:Python Mobile.typeAsString方法的具体用法?Python Mobile.typeAsString怎么用?Python Mobile.typeAsString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rogerthat.rpc.models.Mobile
的用法示例。
在下文中一共展示了Mobile.typeAsString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_json_rpc_user
# 需要导入模块: from rogerthat.rpc.models import Mobile [as 别名]
# 或者: from rogerthat.rpc.models.Mobile import typeAsString [as 别名]
def set_json_rpc_user(user, password, ignore_status=False):
from rogerthat.rpc.models import Mobile
try:
mobile = authenticate_user(user, password)
azzert(mobile)
_tlocal.set_user(mobile=mobile, user=mobile.user, app_id=None, mfr=False)
try:
mobile_string = Mobile.typeAsString(_tlocal.mobile.type)
except ValueError:
mobile_string = str(_tlocal.mobile.type)
logging.info("Request identity: %s (%s)", _tlocal.user, mobile_string)
return True
except:
logging.warn("set_json_rpc_user failed", exc_info=True)
clear_user()
return False
示例2: finish_registration
# 需要导入模块: from rogerthat.rpc.models import Mobile [as 别名]
# 或者: from rogerthat.rpc.models.Mobile import typeAsString [as 别名]
def finish_registration(mobile_account, mobileInfo, accounts, invitor_code, invitor_secret, ipaddress):
from rogerthat.service.api import friends as service_api_friends
m = get_mobile_by_account(mobile_account)
mobile_key = m.key()
ms_key = MobileSettings.get(m).key()
profile_key = get_user_profile_key(m.user)
def trans():
mobile, ms, my_profile = db.get((mobile_key, ms_key, profile_key))
mobile.status = mobile.status | Mobile.STATUS_REGISTERED
mobile.type = mobileInfo.app_type
mobile.simCountry = mobileInfo.sim_country if mobileInfo.sim_country != MISSING else None
mobile.simCountryCode = mobileInfo.sim_country_code if mobileInfo.sim_country_code != MISSING else None
mobile.simCarrierCode = mobileInfo.sim_carrier_code if mobileInfo.sim_carrier_code != MISSING else None
mobile.simCarrierName = mobileInfo.sim_carrier_name if mobileInfo.sim_carrier_name != MISSING else None
mobile.netCountry = mobileInfo.net_country if mobileInfo.net_country != MISSING else None
mobile.netCountryCode = mobileInfo.net_country_code if mobileInfo.net_country_code != MISSING else None
mobile.netCarrierCode = mobileInfo.net_carrier_code if mobileInfo.net_carrier_code != MISSING else None
mobile.netCarrierName = mobileInfo.net_carrier_name if mobileInfo.net_carrier_name != MISSING else None
mobile.hardwareModel = mobileInfo.device_model_name
mobile.osVersion = mobileInfo.device_os_version if mobileInfo.device_os_version != MISSING else None
mobile.localeLanguage = mobileInfo.locale_language if mobileInfo.locale_language and mobileInfo.locale_language != MISSING else DEFAULT_LANGUAGE
mobile.localeCountry = mobileInfo.locale_country
mobile.timezone = mobileInfo.timezone if mobileInfo.timezone != MISSING else None
mobile.timezoneDeltaGMT = mobileInfo.timezone_delta_gmt if mobileInfo.timezone_delta_gmt != MISSING else None
if mobileInfo.app_major_version != MISSING and mobileInfo.app_minor_version != MISSING:
ms.majorVersion = mobileInfo.app_major_version
ms.minorVersion = mobileInfo.app_minor_version
# This is the official place where we set the profile language
my_profile.language = mobile.localeLanguage
my_profile.country = mobile.netCountry or mobile.simCountry or mobile.localeCountry
my_profile.timezone = mobile.timezone
my_profile.timezoneDeltaGMT = mobile.timezoneDeltaGMT
my_profile.mobiles = MobileDetails()
my_profile.mobiles.addNew(mobile.account, mobile.type, mobile.pushId, mobile.app_id)
mobile.put()
ms.put()
my_profile.put()
deferred.defer(_finishup_mobile_registration, mobile, accounts, invitor_code, invitor_secret, ipaddress,
ms_key, _transactional=True)
return mobile, my_profile
xg_on = db.create_transaction_options(xg=True)
mobile, my_profile = db.run_in_transaction_options(xg_on, trans)
channel.send_message(mobile.user, u'com.mobicage.registration.finished')
typestr = "Unknown type"
try:
typestr = Mobile.typeAsString(mobile.type)
except ValueError:
pass
server_settings = get_server_settings()
registration = get_registration_by_mobile(mobile)
if registration:
InstallationLog(parent=registration.installation, timestamp=now(), registration=registration,
mobile=mobile, profile=my_profile, description="Registration successful.").put()
if registration.installation and registration.installation.qr_url:
service_user = get_service_user_from_service_identity_user(registration.installation.service_identity_user)
service_identity = get_identity_from_service_identity_user(registration.installation.service_identity_user)
svc_profile = get_service_profile(service_user)
user_details = [UserDetailsTO.fromUserProfile(my_profile)]
if registration.installation.service_callback_result == ACCEPT_AND_CONNECT_ID:
service_identity_user = create_service_identity_user(service_user, service_identity)
si = get_service_identity(service_identity_user)
bizz_check(si, "ServiceIdentity %s not found" % service_identity_user)
xmpp.send_message(server_settings.xmppInfoMembers,
"User %s registered %s (%s) with account:\n%s\nFor service %s %s" % (
mobile.user, mobile.hardwareModel, typestr, mobile.account, si.name,
service_identity_user), message_type=xmpp.MESSAGE_TYPE_CHAT)
app_id = get_app_id_from_app_user(mobile.user)
if app_id not in si.appIds:
si.appIds.append(app_id)
put_and_invalidate_cache(si)
try_or_defer(makeFriends, mobile.user, service_identity_user, original_invitee=None, servicetag=None,
origin=None, notify_invitee=False, notify_invitor=False, user_data=None)
else:
xmpp.send_message(server_settings.xmppInfoMembers, "User %s registered %s (%s) with account:\n%s" % (
mobile.user, mobile.hardwareModel, typestr, mobile.account), message_type=xmpp.MESSAGE_TYPE_CHAT)
service_api_friends.register_result(register_result_response_receiver, logServiceError, svc_profile,
service_identity=service_identity,
user_details=user_details,
origin=REGISTRATION_ORIGIN_QR)
else:
xmpp.send_message(server_settings.xmppInfoMembers, "User %s registered %s (%s) with account:\n%s" % (
mobile.user, mobile.hardwareModel, typestr, mobile.account), message_type=xmpp.MESSAGE_TYPE_CHAT)
app = get_app_by_id(get_app_id_from_app_user(mobile.user))
if app.admin_services:
service_profiles = filter(None, db.get((get_profile_key(users.User(e)) for e in app.admin_services)))
if service_profiles:
user_details = [UserDetailsTO.fromUserProfile(my_profile)]
#.........这里部分代码省略.........