本文整理汇总了Python中gsocial.log.Log.debug方法的典型用法代码示例。如果您正苦于以下问题:Python Log.debug方法的具体用法?Python Log.debug怎么用?Python Log.debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gsocial.log.Log
的用法示例。
在下文中一共展示了Log.debug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_normalized_parameters
# 需要导入模块: from gsocial.log import Log [as 别名]
# 或者: from gsocial.log.Log import debug [as 别名]
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)
示例2: is_contain
# 需要导入模块: from gsocial.log import Log [as 别名]
# 或者: from gsocial.log.Log import debug [as 别名]
def is_contain(self, userid, target_userid):
"""
二者間でのブラックリストチェック
userid が target_userid をブラックリスト登録してるか?
"""
path = '/blacklist/%s/@all/%s' % (str(userid), str(target_userid))
# ブラックリスト登録してない(データがない)と例外 404
try:
requestor_id = self.request.osuser.userid
self.container.oauth_request('GET', requestor_id, path)
#oauth_request は、例外を出さなくなった
Log.debug("blacklist2 latest_error_code = %s" % self.latest_error_code);
if self.latest_error_code == None:
data = True
Log.debug('Blacklist True. (None)')
elif self.latest_error_code == 200:
data = True
Log.debug('Blacklist True. (200)')
elif self.latest_error_code == 404:
data = False
Log.debug('Blacklist False.(404)')
else:
data = False
Log.error('blacklist2 unexpected error code.')
except:
data = False
Log.debug('Blacklist False. (except)')
return data
示例3: _create_endpoint_url
# 需要导入模块: from gsocial.log import Log [as 别名]
# 或者: from gsocial.log.Log import debug [as 别名]
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
示例4: test_debug
# 需要导入模块: from gsocial.log import Log [as 别名]
# 或者: from gsocial.log.Log import debug [as 别名]
def test_debug(self):
"""
関数が問題なく通るかのみ確認
"""
msg = 'Simplejson Error1.'
obj = 'hoge'
Log.debug(msg, obj)
示例5: encode_emoji
# 需要导入模块: from gsocial.log import Log [as 别名]
# 或者: from gsocial.log.Log import debug [as 别名]
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
示例6: get_or_cache_thumbnail_list
# 需要导入模块: from gsocial.log import Log [as 别名]
# 或者: from gsocial.log.Log import debug [as 别名]
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
示例7: decode_emoji
# 需要导入模块: from gsocial.log import Log [as 别名]
# 或者: from gsocial.log.Log import debug [as 别名]
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
示例8: encode_emoji
# 需要导入模块: from gsocial.log import Log [as 别名]
# 或者: from gsocial.log.Log import debug [as 别名]
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
示例9: _security_check
# 需要导入模块: from gsocial.log import Log [as 别名]
# 或者: from gsocial.log.Log import debug [as 别名]
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
示例10: post
# 需要导入模块: from gsocial.log import Log [as 别名]
# 或者: from gsocial.log.Log import debug [as 别名]
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
示例11: create_rsa_hash
# 需要导入模块: from gsocial.log import Log [as 别名]
# 或者: from gsocial.log.Log import debug [as 别名]
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: get_myself_data
# 需要导入模块: from gsocial.log import Log [as 别名]
# 或者: from gsocial.log.Log import debug [as 别名]
def get_myself_data(self, userid, fields=None, caching=True, cache_update=None):
"""
アプリを利用しているユーザー本人の情報を取得する
任意でキャッシュできる(デフォルトではキャッシュする)
Get the information of user.
You can use caching(default will do it)
"""
path = '/people/%s/@self' % userid
cache_key = path
data = None
if caching:
data = GsocialCache.get_cache(cache_key)
#print 'cache:', data
# dataが空の時、もしくは、キャッシュを更新したい時
if data == None or cache_update == True:
#print 'not cache:', data
#print 'cache_update:', cache_update
params = {}
if fields:
params['fields'] = fields
res = self.get_response(userid, path, params)
Log.debug('Debug.', res)
if res:
try:
data = simplejson.loads(res)
if caching:
GsocialCache.set_cache(cache_key, data)
except TypeError:
Log.error(self.LOG_MSG2, [userid, path, res])
try:
data = simplejson.loads(unicode(res, "utf-8", "ignore"))
if caching:
GsocialCache.set_cache(cache_key, data)
except TypeError:
data = None
Log.error(self.LOG_MSG3, [userid, path, res])
except Exception:
data = None
Log.error(self.LOG_MSG1, [userid, path, res])
except Exception:
data = None
Log.error(self.LOG_MSG1, [userid, path, res])
else:
data = None
Log.error(self.LOG_MSG4, [userid, path])
return data
示例13: create_hmac_hash
# 需要导入模块: from gsocial.log import Log [as 别名]
# 或者: from gsocial.log.Log import debug [as 别名]
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
# 需要导入模块: from gsocial.log import Log [as 别名]
# 或者: from gsocial.log.Log import debug [as 别名]
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: create_record
# 需要导入模块: from gsocial.log import Log [as 别名]
# 或者: from gsocial.log.Log import debug [as 别名]
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