本文整理汇总了Python中gsocial.log.Log类的典型用法代码示例。如果您正苦于以下问题:Python Log类的具体用法?Python Log怎么用?Python Log使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Log类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_endpoint_url
def _create_endpoint_url(self, path, secure=False, url_tail=None):
"""
FP/SP/WEBVIEW判定し対応したendpoint_urlを返す
"""
protocol = "https" if secure else "http"
from mobilejp.middleware.mobile import get_current_device
device = get_current_device()
if device:
if device.is_webview:
endpoint = self.container["endpoint_webview"]
elif device.is_smartphone:
endpoint = self.container["endpoint_sp"]
else:
endpoint = self.container["endpoint_fp"]
else:
endpoint = self.container["endpoint_fp"]
Log.debug("url_tail %s " % url_tail)
if url_tail or url_tail == "":
url = "%s://%s%s%s" % (protocol, endpoint, url_tail, path)
else:
url = "%s://%s%s%s" % (protocol, endpoint, self.container["api_url_tail"], path)
return url
示例2: encode_emoji
def encode_emoji(self, text):
"""
Encode "Emoji" and return it.
For Gree`s InspectionAPI
eg. \ue000 -> 
argument:
text
return value:
encoded "emoji"
絵文字をエンコードして返す
GREEのInspectionAPI、モバゲーのTextDataAPI用
\ue000 ->  に変換
引数
text
返り値
エンコードした絵文字を返す
"""
Log.debug("encode_emoji before: %r" % text)
if self.emoji_re is None:
self.emoji_re = re.compile(u"[\ue000-\uf0fc]")
def emoji_open(m):
return "&#x%x" % ord(m.group(0))
encoded = self.emoji_re.sub(emoji_open, text)
Log.debug("encode_emoji after: %r" % encoded)
return encoded
示例3: get_or_cache_thumbnail_list
def get_or_cache_thumbnail_list(self):
"""
cacheがなければAPIgetする
"""
url_list = {}
path = self.thumbnail_path_key()
try:
data = cache.get(path, None)
if data:
Log.debug("data %s" % data)
url_list = msgpack.unpackb(data)
Log.debug("data url_list %s" % url_list)
else:
request = get_current_request()
request_params = [value for key,value in self.THUMBNAIL_MAPS.items()]
request_params = (',').join(request_params)
profile = People(request).get_myself(self.id, request_params, caching=False)
for key, value in self.THUMBNAIL_MAPS.items():
url_list[value] = profile[value]
Log.debug("new data url_list %s" % url_list)
pack_data = msgpack.packb(url_list)
Log.debug("pack_data url_list %s" % pack_data)
cache.set(path, pack_data, timeout=self.CACHE_TIME)
except:
url_list = {}
Log.debug("return url_list %s" % url_list)
return url_list
示例4: get_normalized_parameters
def get_normalized_parameters(self):
"""
Return a string that contains the parameters that must be signed.
"""
Log.debug("[Method] get_normalized_parameters")
params = self.parameters
try:
# Exclude the signature if it exists.
del params['oauth_signature']
except:
pass
# Escape key values before sorting.
key_values = []
for key, value in params.iteritems():
if isinstance(key, basestring) and not _is_post_values_key(key):
key_values.append((escape(_utf8_str(key)), escape(_utf8_str(value))))
else:
try:
value = list(value)
except TypeError, e:
assert 'is not iterable' in str(e)
key_values.append((escape(_utf8_str(key)), escape(_utf8_str(value))))
else:
if _is_post_values_key(key):
key = _remove_post_values_key(key)
key_values.extend((escape(_utf8_str(key)), escape(_utf8_str(item)) if isinstance(item, basestring) else item) for item in value)
示例5: decode_emoji
def decode_emoji(self, text):
"""
絵文字をデコードして返す
GREEのInspectionAPI、モバゲーのTextDataAPI用
 -> \ue000に変換
絵文字じゃない &#xXXXX は空文字にする
引数
text
返り値
デコードした絵文字を返す
"""
if self.emoji_re is None:
self.emoji_re = re.compile(u"[\ue000-\uf0fc]")
if self.emoji_decode_re is None:
self.emoji_decode_re = re.compile(r"&#x(\w{4})")
Log.debug("decode_emoji before: %r" % text)
def emoji_close(m):
"""
emoji_close
"""
c = unichr(int(m.group(1), 16))
if self.emoji_re.search(c):
return c
else:
return ""
decoded = self.emoji_decode_re.sub(emoji_close, text)
Log.debug("decode_emoji after: %r" % decoded)
return decoded
示例6: _security_check
def _security_check(request, session_id):
"""
Security check using cookie
cookieによるセキュリティチェック
"""
#リクエストサービスのコールバックにcookieチェックは不要
if settings.GREE_REQUEST_API and request.path == reverse(settings.GREE_REQUEST_API_HEADER):
return True
from mobilejp.middleware.mobile import get_current_device
device = get_current_device()
Log.debug("_security_check device.is_webview %s" % device.is_webview)
if device.is_webview:
Log.debug("[Method] _security_check webview Pass")
return True
Log.debug("[Method] _security_check ")
ua = request.META.get('HTTP_USER_AGENT', None)
if ua is None:
return False
security_name = request.COOKIES.get(_get_security_name(), u'')
m = hashlib.md5()
m.update(ua)
m.update(str(session_id))
Log.debug("[Method] _security_check security_name: %s", security_name)
Log.debug("[Method] _security_check m.hexdigest: %s", m.hexdigest())
return m.hexdigest() == security_name
示例7: encode_emoji
def encode_emoji(self, text):
"""
絵文字をエンコードして返す
GREEのInspectionAPI、モバゲーのTextDataAPI用
\ue000 ->  に変換
引数
text
返り値
エンコードした絵文字を返す
"""
if self.emoji_re is None:
self.emoji_re = re.compile(u"[\ue000-\uf0fc]")
Log.debug("encode_emoji before: %r" % text)
def emoji_open(m):
"""
emoji_open
"""
return "&#x%x" % ord(m.group(0))
encoded = self.emoji_re.sub(emoji_open, text)
Log.debug("encode_emoji after: %r" % encoded)
return encoded
示例8: post
def post(self, userid, message):
'''
POST(新規登録)
戻したJSONのtextIdを用いることで再度このテキストにアクセスすることができる
POST(Newly register)
You can access to this text using the textId of returned JSON.
'''
# ローカルではリクエストできない
# You can`t request on local.
if settings.OPENSOCIAL_DEBUG:
return None
message = self.container.encode_emoji(message)
data = simplejson.dumps({'data': message})
text_id = None
json = None
response = self._api_request('POST', userid, data = data)
Log.debug('Inspection POST. response: %s' % (response))
json = simplejson.loads(response)
if 'entry' in json:
entry = json['entry'][0]
if 'textId' in entry:
text_id = entry['textId']
Log.debug('Inspection: post: textId:%s' % text_id)
if not json:
error = self.container.ResponseError('post', 'Inspection POST')
raise error
return text_id
示例9: test_warn
def test_warn(self):
"""
関数が問題なく通るかのみ確認
"""
msg = 'Simplejson Error4.'
obj = 'hoge'
Log.info(msg, obj)
示例10: test_debug
def test_debug(self):
"""
関数が問題なく通るかのみ確認
"""
msg = 'Simplejson Error1.'
obj = 'hoge'
Log.debug(msg, obj)
示例11: create_rsa_hash
def create_rsa_hash(request, params):
"""
create_rsa_hash
"""
Log.debug("[Method] create_rsa_hash")
message = create_message(request, params)
return hashlib.sha1(message).digest()
示例12: create_record
def create_record(self, auth_id, is_authorized = False, user_grade=None):
"""
認証レコード作成
作成したAuthDeviceモデルインスタンスを返す
"""
Log.debug('Check is_authorized.', is_authorized)
auth = AuthDevice.objects.partition(self.user_id).create(
osuser_id=self.user_id, auth_id=auth_id,
user_grade=user_grade, is_authorized=is_authorized)
GsocialCache.set_cache(self.cache_key, None, 1) # キャッシュ削除
return auth
示例13: create_hmac_hash
def create_hmac_hash(request, params, oauth_token_secret):
"""
create_hmac_hash
"""
Log.debug("[Method] create_hmac_hash")
message = create_message(request, params)
shared_key = '%s&%s' % (oauth.escape(settings.CONSUMER_SECRET),
oauth.escape(oauth_token_secret))
hashed = hmac.new(shared_key, message, hashlib.sha1)
return hashed.digest()
示例14: _get_security_name
def _get_security_name():
"""
Creates a key which wil be used in Cookie-security-check
If there is no "SECURITY_COOKIE_NAME" in settings.py,this will
be option.
cokkieによるセキュリティチェックのkey生成
settings.pyに「SECURITY_COOKIE_NAME」がなければoptionになる
"""
Log.debug("[Method] _get_security_name")
return getattr(settings, 'SECURITY_COOKIE_NAME', 'option')
示例15: _get_id_from_result
def _get_id_from_result(self, result_json):
"""
保存結果jsonから登録IDを取得
"""
if result_json:
try:
result_dict = simplejson.loads(result_json)
except simplejson.JSONDecodeError, e:
Log.warn(e)
return None
else:
return result_dict['entry'][0]['id']