本文整理汇总了Python中mcfw.properties.azzert函数的典型用法代码示例。如果您正苦于以下问题:Python azzert函数的具体用法?Python azzert怎么用?Python azzert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了azzert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_local_services
def run_local_services(app_user, ipaddress, auto_connected_service, service_helper):
logging.debug("Checking if %s (ip: %s) is in %s for %s",
app_user, ipaddress, auto_connected_service.local, auto_connected_service.service_identity_email)
profile = get_user_profile(app_user)
if not profile.language:
logging.info("Can't connect %s to %s. User has no language set.",
app_user, auto_connected_service.service_identity_email)
return
if profile.country:
country_code = profile.country
elif ipaddress:
country_code = get_country_code_by_ipaddress(ipaddress)
azzert(country_code)
else:
logging.info("Can't connect %s to %s if there is no ip address, and no country in UserProfile.",
app_user, auto_connected_service.service_identity_email)
return
local_service_map_key = "%s-%s" % (profile.language, country_code.lower())
if local_service_map_key in auto_connected_service.local:
deferred.defer(hookup, app_user, auto_connected_service, service_helper, _queue=HIGH_LOAD_WORKER_QUEUE)
else:
logging.info("Not connecting to %s. There is no entry for local key %s",
auto_connected_service.service_identity_email, local_service_map_key)
示例2: trans
def trans(): # Operates on 2 entity groups
hookup_with_default_services.schedule(mobile_user, ipaddress)
deferred.defer(sync_payment_database, mobile_user, _transactional=True)
if invitor_code and invitor_secret:
pp = ProfilePointer.get(invitor_code)
if not pp:
logging.error("User with userCode %s not found!" % invitor_code)
else:
deferred.defer(ack_invitation_by_invitation_secret, mobile_user, pp.user, invitor_secret,
_transactional=True, _countdown=10)
elif invitor_code:
for ysaaa_hash, static_email in chunks(server_settings.ysaaaMapping, 2):
if invitor_code == ysaaa_hash:
service_user = users.User(static_email)
makeFriends(service_user, mobile_user, original_invitee=None, servicetag=None, origin=ORIGIN_YSAAA)
break
else:
azzert(False, u"ysaaa registration received but not found mapping")
for _, static_email in chunks(server_settings.staticPinCodes, 2):
if mobile_user.email() == static_email:
break
else:
deferred.defer(send_messages_after_registration, mobile_key, _transactional=True)
示例3: get
def get(self, info):
try:
padding = ""
while True:
try:
data = base64.b64decode(info + padding)
break
except TypeError:
if len(padding) < 2:
padding += "="
else:
raise
json_params = json.loads(data)
parent_message_key = json_params['parent_message_key']
message_key = json_params['message_key']
azzert(message_key, "message_key is required")
if parent_message_key == "":
parent_message_key = None
except:
logging.exception("Error in ServiceDownloadPhotoHandler")
self.error(404)
return
logging.debug("Download photo %s %s" % (parent_message_key, message_key))
photo_upload_result = get_transfer_result(parent_message_key, message_key)
if not photo_upload_result:
self.error(404)
return
azzert(photo_upload_result.status == photo_upload_result.STATUS_VERIFIED)
self.response.headers['Content-Type'] = "image/jpeg" if photo_upload_result.content_type == None else str(photo_upload_result.content_type)
self.response.out.write(assemble_transfer_from_chunks(photo_upload_result.key()))
示例4: parse_data
def parse_data(self, email, data):
user = users.User(email)
data = base64.decodestring(data)
data = decrypt(user, data)
data = json.loads(data)
azzert(data["d"] == calculate_secure_url_digest(data))
return data, user
示例5: get
def get(self):
service_user = users.get_current_user()
azzert(get_service_profile(service_user)) # must exist
message_flow_designs = get_service_message_flow_designs(service_user)
result = []
for wiring in message_flow_designs:
if wiring.deleted or not wiring.definition:
continue
wiringDefinition = json.loads(wiring.definition)
for k in wiringDefinition.iterkeys():
if k == u"modules":
for m in wiringDefinition[k]:
if m["value"]:
m["config"]["formMessageDef"] = m["value"]
result.append({"name": wiring.name, "language": wiring.language, "working": json.dumps(wiringDefinition)})
if not result:
wiring_id = "Sample message flow"
language = "MessageFlow"
result.append({"name": wiring_id, "language": language, "working": SAMPLE_MF})
message_flow_design = MessageFlowDesign(parent=parent_key(service_user), key_name=wiring_id)
message_flow_design.definition = SAMPLE_MF
message_flow_design.name = wiring_id
message_flow_design.language = language
message_flow_design.design_timestamp = now()
message_flow_design.status = MessageFlowDesign.STATUS_VALID
message_flow_design.js_flow_definitions = JsFlowDefinitions()
message_flow_design.put()
self.response.out.write(json.dumps(result))
示例6: get_friend_service_identity_connections_keys_of_app_user_query
def get_friend_service_identity_connections_keys_of_app_user_query(app_user):
app_user_email = app_user.email()
azzert('/' not in app_user_email, 'no slash expected in %s' % app_user_email)
qry = db.GqlQuery("SELECT __key__ FROM FriendServiceIdentityConnection"
" WHERE ANCESTOR IS :ancestor AND deleted = False")
qry.bind(ancestor=parent_key(app_user))
return qry
示例7: get_child_messages
def get_child_messages(app_user, parent_messages):
child_messages = list()
for m in parent_messages:
azzert(app_user in m.members)
for key in m.childMessages:
child_messages.append(key)
return db.get(child_messages)
示例8: get_friend_service_identity_connections_of_service_identity_keys_query
def get_friend_service_identity_connections_of_service_identity_keys_query(service_identity_user):
azzert('/' in service_identity_user.email(), 'no slash in %s' % service_identity_user.email())
qry = db.GqlQuery("SELECT __key__ FROM FriendServiceIdentityConnection "
"WHERE deleted = False AND service_identity_email = :service_identity_email "
"ORDER BY friend_name ASC")
qry.bind(service_identity_email=service_identity_user.email())
return qry
示例9: trans_create
def trans_create(avatar, image, share_sid_key):
azzert(not get_service_profile(service_user, cached=False))
azzert(not get_default_service_identity_not_cached(service_user))
profile = ServiceProfile(parent=parent_key(service_user), key_name=service_user.email())
profile.avatarId = avatar.key().id()
_calculateAndSetAvatarHash(profile, image)
service_identity_user = create_service_identity_user(service_user, ServiceIdentity.DEFAULT)
service_identity = ServiceIdentity(key=ServiceIdentity.keyFromUser(service_identity_user))
service_identity.inheritanceFlags = 0
service_identity.name = name
service_identity.description = "%s (%s)" % (name, service_user.email())
service_identity.shareSIDKey = share_sid_key
service_identity.shareEnabled = False
service_identity.creationTimestamp = now()
service_identity.defaultAppId = supported_app_ids[0]
service_identity.appIds = supported_app_ids
update_result = update_func(profile, service_identity) if update_func else None
put_and_invalidate_cache(profile, service_identity,
ProfilePointer.create(service_user),
ProfileHashIndex.create(service_user))
deferred.defer(create_default_qr_templates, service_user, _transactional=True)
deferred.defer(create_default_news_settings, service_user, profile.organizationType, _transactional=True)
return profile, service_identity, update_result
示例10: get_message_flow_design_keys_by_sub_flow_key
def get_message_flow_design_keys_by_sub_flow_key(flow_key):
kind = MessageFlowDesign.kind()
azzert(flow_key.kind() == kind)
qry = MessageFlowDesign.gql("WHERE sub_flows = :flow AND ANCESTOR IS :ancestor AND deleted = false")
qry.bind(flow=flow_key, ancestor=flow_key.parent())
for mfd in qry.run():
yield mfd.key()
示例11: get_service_identity_details
def get_service_identity_details(identifier):
azzert(identifier)
service_user = users.get_current_user()
service_identity_user = create_service_identity_user(service_user, identifier)
service_identity = get_service_identity_not_cached(service_identity_user)
service_profile = get_service_profile(service_user, cached=False)
return ServiceIdentityDetailsTO.fromServiceIdentity(service_identity, service_profile)
示例12: _perform_call
def _perform_call(callId, request_json, timestamp):
api_version, callid, function, parameters = parse_and_validate_request(request_json)
if not function:
result = {
CALL_ID: callId,
API_VERSION: api_version,
ERROR: "Unknown function call!",
STATUS: STATUS_FAIL,
CALL_TIMESTAMP: timestamp}
return json.dumps(result), result
azzert(callid == callId)
result = dict()
result[CALL_ID] = callid
result[API_VERSION] = api_version
result[CALL_TIMESTAMP] = timestamp
try:
check_function_metadata(function)
kwarg_types = get_parameter_types(function)
kwargs = get_parameters(parameters, kwarg_types)
for key in set(kwarg_types.keys()) - set(kwargs.keys()):
kwargs[key] = MISSING
result[RESULT] = run(function, [], kwargs)
result[STATUS] = STATUS_SUCCESS
return json.dumps(result), result
except Exception, e:
result[ERROR] = unicode(e)
result[STATUS] = STATUS_FAIL
from rogerthat.rpc.service import ServiceApiException, ApiWarning
if isinstance(e, (ServiceApiException, ApiWarning)):
loglevel = logging.WARNING
else:
loglevel = logging.ERROR
logging.log(loglevel, "Error while executing %s: %s" % (function.__name__, traceback.format_exc()))
return json.dumps(result), result
示例13: get_full_language_string
def get_full_language_string(short_language):
""" Map short language ('en', 'fr') to long language str ('English', 'French (Français)') """
language = OFFICIALLY_SUPPORTED_ISO_LANGUAGES.get(short_language)
if language is None:
language = OFFICIALLY_SUPPORTED_LANGUAGES.get(short_language)
azzert(language)
return language
示例14: update_profile_from_profile_discovery
def update_profile_from_profile_discovery(app_user, discovery):
azzert(discovery.user == app_user)
changed_properties = []
user_profile = get_user_profile(app_user)
new_name = discovery.name.strip()
if user_profile.name != new_name:
changed_properties.append(u"name")
user_profile.name = new_name
if discovery.avatar:
img = images.Image(str(discovery.avatar))
img.resize(150, 150)
avatar = get_avatar_by_id(user_profile.avatarId)
if not avatar:
avatar = Avatar(user=app_user)
image = img.execute_transforms(images.PNG, 100)
avatar.picture = db.Blob(image)
avatar.put()
user_profile.avatarId = avatar.key().id()
_calculateAndSetAvatarHash(user_profile, image)
changed_properties.append(u"avatar")
user_profile.version += 1
user_profile.put()
update_mobiles(app_user, user_profile)
update_friends(user_profile, changed_properties)
示例15: get
def get(self):
data_dict, app_user = self.get_user_info()
if not data_dict or not app_user:
return
azzert(data_dict['a'] == "unsubscribe broadcast")
broadcast_type = data_dict['bt']
si_user = users.User(data_dict['e'])
_, user_profile, si, fsic = run_in_xg_transaction(self._un_subscribe, app_user, si_user, broadcast_type)
if fsic or not si:
message = '%s,<br><br>%s' % (xml_escape(localize(user_profile.language, u'dear_name',
name=user_profile.name)),
xml_escape(localize(user_profile.language,
u'successfully_unsubscribed_broadcast_type',
notification_type=broadcast_type,
service=si.name if si else data_dict['n'])))
else:
language = get_languages_from_request(self.request)[0]
if not user_profile:
# User already deactivated his account
human_user, app_id = get_app_user_tuple(app_user)
message = localize(language, u'account_already_deactivated',
account=human_user.email(), app_name=get_app_name_by_id(app_id))
else:
# User is not connected anymore to this service identity
message = localize(language, u'account_already_disconnected_from_service',
service_name=si.name)
jinja_template = self.get_jinja_environment().get_template('unsubscribe_broadcast_type.html')
self.response.out.write(jinja_template.render(dict(message=message)))