本文整理汇总了Python中snsapi.snslog.SNSLog.debug方法的典型用法代码示例。如果您正苦于以下问题:Python SNSLog.debug方法的具体用法?Python SNSLog.debug怎么用?Python SNSLog.debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类snsapi.snslog.SNSLog
的用法示例。
在下文中一共展示了SNSLog.debug方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tag_add
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import debug [as 别名]
def tag_add(self, name):
cur = self.con.cursor()
r = cur.execute('''
INSERT INTO tag(name, visible)
VALUES(?, ?)
''', (name, 1))
logger.debug("Add tag %s", name)
self.refresh_tags()
示例2: run
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import debug [as 别名]
def run(self):
while (self.keep_running):
try:
self.queue.input()
logger.debug("Invoke input() on queue")
time.sleep(INPUT_GAP)
except Exception as e:
logger.warning("Catch Exception in InputThread: %s", e)
示例3: tag_toggle
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import debug [as 别名]
def tag_toggle(self, tag_id):
cur_visible = self.tags_all[tag_id]['visible']
cur = self.con.cursor()
r = cur.execute('''
UPDATE tag
SET visible=?
WHERE id=?
''', (1 - cur_visible, tag_id))
logger.debug("Set tag %d to visibility %d", tag_id, 1 - cur_visible)
示例4: rand_execute
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import debug [as 别名]
def rand_execute(prob, func):
if prob >= 1.0:
func()
else:
if random.random() < prob:
logger.debug('func execute. prob: %f', prob)
return func()
else:
logger.debug('func do not execute. prob: %f', prob)
示例5: hook_new_message
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import debug [as 别名]
def hook_new_message(q, msg):
mymsg = False
sp = q.sp
for ch in sp.values():
if 'user_name' in ch.jsonconf:
user_name = ch.jsonconf['user_name']
if user_name == msg.parsed.username:
mymsg = True
if mymsg:
logger.debug('distribute message: %s', msg)
distribute.update(msg)
示例6: run
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import debug [as 别名]
def run(self):
#webbrowser.open("http://127.0.0.1:8080/login")
while (self.keep_running):
self.queue.input()
try:
logger.debug("Invoke input() on queue")
os.chdir("." + delimeter + "User" + delimeter + str(self.user_id))
p = os.getcwd()
self.sp.save_config(fn_channel= p + delimeter + "conf" + delimeter + "channel.json",fn_pocket= p + delimeter + "conf" + delimeter + "pocket.json")
os.chdir(".." + delimeter + ".." + delimeter)
time.sleep(INPUT_GAP)
except Exception as e:
logger.warning("Catch Exception in InputThread: %s", e)
示例7: sql
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import debug [as 别名]
def sql(self, query_string):
cur = self.con.cursor()
try:
r = cur.execute(query_string)
logger.debug("SQL query string: %s", query_string)
message_list = snstype.MessageList()
for m in r:
obj = self._str2pyobj(m[1])
obj.msg_id = m[0]
message_list.append(obj)
return message_list
except Exception, e:
logger.warning("Catch exception when executing '%s': %s", query_string, e)
return snstype.MessageList()
示例8: sql
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import debug [as 别名]
def sql(self, condition):
cur = self.con.cursor()
try:
# We trust the client string. This software is intended for personal use.
qs = "SELECT DISTINCT msg.id,msg.pyobj FROM msg,msg_tag WHERE %s" % condition
r = cur.execute(qs)
logger.debug("SQL query string: %s", qs)
message_list = snstype.MessageList()
for m in r:
obj = self._str2pyobj(m[1])
obj.msg_id = m[0]
message_list.append(obj)
return message_list
except Exception, e:
logger.warning("Catch exception when executing '%s': %s", condition, e)
return snstype.MessageList()
示例9: tag_add
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import debug [as 别名]
def tag_add(self, name):
cur = self.con.cursor()
r = cur.execute('''
SELECT id FROM tag WHERE name=?
''', (name, ))
for t in cur:
if type(t[0]) == int:
return "Duplicate tag found."
r = cur.execute('''
INSERT INTO tag(name, visible)
VALUES(?, ?)
''', (name, 1))
logger.debug("Add tag %s", name)
self.refresh_tags()
r = cur.execute('''
SELECT id FROM tag WHERE name=?
''', (name, ))
for t in cur:
return t[0]
示例10: _dummy_decorator_generator
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import debug [as 别名]
from snsapi.snspocket import SNSPocket
from snsapi.snslog import SNSLog as logger
from lbucket import *
try:
_wauto_conf = json.loads(open('conf/wauto.json').read())
except Exception, e:
logger.warning("Load conf error: %s. Use default", e)
_wauto_conf = {}
_wauto_conf['priority'] = {
'update': 5,
'home_timeline': 4,
'forward': 3,
'reply': 3
}
logger.debug("conf: %s", _wauto_conf)
'''
Make the invokation from Python interpreter more convenient.
Use synchronous calls.
'''
def _dummy_decorator_generator(*args, **kwargs):
def _dummy_decorator(func):
return func
return _dummy_decorator
if __name__ == '__main__':
rate_limit = _dummy_decorator_generator
def cal_bucket(upperbound, period):
'''
示例11: SRFEQueue
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import debug [as 别名]
q = SRFEQueue(sp)
q.connect()
q.refresh_tags()
try:
jsonconf = json.load(open('conf/srfe.json', 'r'))
except IOError:
logger.warning("Do not find conf/srfe.json, use defaults")
jsonconf = {
"cookie_sign_key": "You had better set your own key in the config!!!!",
"username": "test",
"password": "test"
}
INPUT_GAP = jsonconf.get('input_gap', 60 * 5) # 5 Minutes per fetch
logger.debug("INPUT_GAP: %s", INPUT_GAP)
class InputThread(threading.Thread):
def __init__(self, queue):
super(InputThread, self).__init__()
self.queue = queue
self.keep_running = True
def run(self):
while (self.keep_running):
try:
self.queue.input()
logger.debug("Invoke input() on queue")
time.sleep(INPUT_GAP)
except Exception as e:
logger.warning("Catch Exception in InputThread: %s", e)
示例12: _inqueue
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import debug [as 别名]
def _inqueue(self, message):
cur = self.con.cursor()
try:
# Deduplicate
# Explain the problem of the following two methods for future reference:
# 1. digest = self._digest_pyobj(message)
# Python object are hashed to different values even the SNS message
# fields are all the same.
# 2. digest = message.digest_parsed()
# I forget what is the problem.. I should have noted before.
digest = message.digest()
#logger.debug("message pyobj digest '%s'", digest)
r = cur.execute('''
SELECT digest FROM msg
WHERE digest = ?
''', (digest, ))
if len(list(r)) > 0:
#logger.debug("message '%s' already exists", digest)
return False
else:
logger.debug("message '%s' is new", digest)
self._hook_new_message(self, message)
#TODO:
# This is temporary solution for object digestion.
#
# For our Message object, the following evaluates to False!!
# Serialize.dumps(o) == Serialize.dumps(Serialize.loads(Serialize.dumps(o)))
#
# To perform deduplication and further refer to this message,
# we store the calculated digestion as an attribute of the message.
# Note however, after this operation the digest of 'message' will not
# be the valued stored therein! This is common problem in such mechanism,
# e.g. UDP checksum. Developers should have this in mind.
message.digest_pyobj = self._digest_pyobj(message)
cur.execute('''
INSERT INTO msg(
time ,
text ,
userid ,
username ,
mid ,
platform ,
digest ,
digest_parsed ,
digest_pyobj ,
parsed ,
pyobj ,
flag ,
weight ,
weight_time
)
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)
''', (\
message.parsed.time,\
message.parsed.text,\
message.parsed.userid,\
message.parsed.username,\
str(message.ID),\
message.platform,\
message.digest(),\
message.digest_parsed(),\
#self._digest_pyobj(message),\
message.digest_pyobj,\
message.dump_parsed(),\
self._pyobj2str(message),\
"unseen",
self._weight_feature(message),
int(self.time())
))
return True
except Exception, e:
logger.warning("failed: %s", str(e))
#print message
#raise e
return False
示例13: run
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import debug [as 别名]
def run(self):
while (self.keep_running):
self.queue.input()
logger.debug("Invoke input() on queue")
time.sleep(60 * 5) # 5 Minutes per fetch