本文整理汇总了Python中snsapi.snslog.SNSLog.warning方法的典型用法代码示例。如果您正苦于以下问题:Python SNSLog.warning方法的具体用法?Python SNSLog.warning怎么用?Python SNSLog.warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类snsapi.snslog.SNSLog
的用法示例。
在下文中一共展示了SNSLog.warning方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import warning [as 别名]
def __init__(self, snspocket = None):
super(SRFEQueue, self).__init__(self.SQLITE_QUEUE_CONF)
self.sp = snspocket # SNSPocket object
self.msgMapping = {
"Email":1,
"FacebookFeed":2,
"RSS":3,
"RSS2RW":4,
"RSSSummary":5,
"RenrenBlog":6,
"RenrenFeed": 7,
"RenrenPhoto": 8,
"RenrenShare":9,
"RenrenStatus":10,
"RenrenStatusDirect": 11,
"SQLite":12,
"SinaWeiboBase":13,
"SinaWeiboStatus":14,
"SinaWeiboWapStatus":15,
"TencentWeiboStatus":16,
"TwitterStatus":17,
"InstagramFeed":18,
"DoubanFeed":19}
self.platform_num = 19
self.inputnum = 10
self.condLast = time.time()
try:
self.queue_conf = json.loads(open('conf' + delimeter + 'queue.json', 'r').read())
except IOError, e:
logger.warning("No conf/queue.json, use defaults")
self.queue_conf = {}
示例2: config
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import warning [as 别名]
def config():
info = {}
(k, sp, ap, q) = token_to_user(request.get_cookie('token'))
pr = get_preference(k)
if sp is None:
return {"info": {}, "sp": {}, "ap": {}, "q": {}}
for ch in sp:
info[ch] = sp[ch].jsonconf
info[ch]['expire_after'] = int(sp[ch].expire_after())
info[ch]['is_authed'] = sp[ch].is_authed()
info[ch]['need_auth'] = sp[ch].need_auth()
con_user = sqlite3.connect("." + delimeter + "User" + delimeter + str(k) + delimeter + "srfe_queue.db", check_same_thread = False)
con_user.isolation_level = None
cur_user = con_user.cursor()
r = cur_user.execute("SELECT platform, toggle FROM msg_toggle WHERE toggle <> 2")
for m in r:
for ch in info.values():
logger.warning(str(ch))
logger.warning(str(m[0]))
if ch["platform"] == m[0]:
ch["toggle"] = m[1]
r = cur_user.execute("SELECT id, username, platform, toggle FROM user_toggle")
bu = {}
for m in r:
bu[str(m[0])] = {
"id": m[0],
"username": m[1],
"platform": m[2],
"toggle": m[3]
}
return {"info": info, "sp": sp, "ap": ap, "q": q, "pr":pr, "bu": bu}
示例3: wrapper_check_login
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import warning [as 别名]
def wrapper_check_login(*al, **ad):
logger.warning(str(user))
token = request.get_cookie("token")
if not check_token(token):
redirect('/login')
else:
return func(*al, **ad)
示例4: select_samples
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import warning [as 别名]
def select_samples(message):
candidates = {}
null_msg = []
for m in message['seen_list']:
if len(m.tags) >= 1:
#candidates.append(m)
candidates[m.msg_id] = m
else:
null_msg.append(m)
logger.warning(str(len(message['seen_list'])))
# Sample same number of null tag messages
prob = float(len(candidates)) / (len(message['seen_list']) - len(candidates))
if prob > 1.0:
prob = 1.0
print "Selecting null message probability: %.3f" % (prob)
for m in null_msg:
if random.random() < prob:
#m.tags = {"null": 1}
# All tag id is greater than or equal to 1.
# 0 is reserved as "null" tag if the user has not defined one.
m.tags = {0: 1}
#candidates.append(m)
candidates[m.msg_id] = m
print "Total %d samples extracted" % (len(candidates))
return candidates
示例5: run
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import warning [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)
示例6: __init__
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import warning [as 别名]
def __init__(self, snspocket = None):
super(SRFEQueue, self).__init__(self.SQLITE_QUEUE_CONF)
self.sp = snspocket # SNSPocket object
try:
self.queue_conf = json.loads(open('conf/queue.json', 'r').read())
except IOError, e:
logger.warning("No conf/queue.json, use defaults")
self.queue_conf = {}
示例7: config_preference_add
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import warning [as 别名]
def config_preference_add():
k = token_to_user_key(request.get_cookie('token'))
for (w,l) in zip(request.forms.getall("winner"), request.forms.getall("loser")):
if not [w,l] in user_sp[k]["pr"]["preference"] and w != l:
user_sp[str(k)]["pr"]["preference"].append([w, l])
try:
json.dump(user_sp[str(k)]["pr"], open('." + delimeter + "User" + delimeter + "' + str(k) + '" + delimeter + "conf" + delimeter + "autoweight.json', "w"))
except Exception as e:
logger.warning("Catch Exception in InputThread: %s", e)
return "Preference has been added!"
示例8: load_weight
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import warning [as 别名]
def load_weight(self, fn = None):
if fn is None:
fn = 'conf/weights.json'
try:
self.feature_weight = json.loads(open(fn, 'r').read())
self.feature_name = self.feature_weight.keys()
logger.info("Loaded weights: %s", self.feature_weight)
except IOError:
logger.warning("No '%s' weights config file, use empty setting.", fn)
self.feature_weight = {}
self.feature_name = self.feature_weight.keys()
示例9: run
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import warning [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)
示例10: user_toggle
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import warning [as 别名]
def user_toggle(self, msg_id):
cur = self.con.cursor()
try:
r = cur.execute('''
SELECT pyobj FROM msg
WHERE id=?
''', (msg_id, ))
str_obj = r.next()[0]
message = self._str2pyobj(str_obj)
except Exception, e:
logger.warning("Catch exception: %s", e)
return
示例11: home_timeline
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import warning [as 别名]
def home_timeline():
(k, sp, ap, q) = token_to_user(request.get_cookie('token'))
(sl, tl) = q.output(q.inputnum)
logger.warning(str(len(tl)))
meta = {
"unseen_count": q.get_unseen_count()
}
if len(sl) > 0:
q.condLast = sl[-1].parsed.time
mp = {}
for (s,v) in sp.items():
mp[s] = q.msgMapping[v.platform]
return {'sl': sl, 'mp': mp, 'tl': tl, 'snsapi_utils': snsapi_utils, 'tags': q.get_tags(), 'meta': meta, "token" : request.get_cookie('token')}
示例12: get_unseen_count
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import warning [as 别名]
def get_unseen_count(self):
cur = self.con.cursor()
r = cur.execute('''
SELECT count(*) FROM msg
WHERE flag='unseen'
''')
try:
return r.next()[0]
except Exception, e:
logger.warning("Catch Exception: %s", e)
return -1
示例13: reweight_all
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import warning [as 别名]
def reweight_all(self, younger_than = 86400):
begin = self.time()
cur = self.con.cursor()
try:
latest_time = int(self.time() - younger_than)
r = cur.execute('''
SELECT id from msg
WHERE time >= ?
''', (latest_time, ))
for m in r:
self.reweight(m[0])
except Exception, e:
logger.warning("Catch exception: %s", e)
return False
示例14: sql
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import warning [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()
示例15: auth_second
# 需要导入模块: from snsapi.snslog import SNSLog [as 别名]
# 或者: from snsapi.snslog.SNSLog import warning [as 别名]
def auth_second():
(k, sp, ap, q) = token_to_user(request.get_cookie('token'))
op = "auth_second for %s" % (ap.current_channel)
qs = request.query_string
# For compatibility with lower level interface.
# The snsbase parses code from the whole url.
ap.code_url = "http://snsapi.snsapi/auth/second/auth?%s" % qs
sp[ap.current_channel].auth_second()
logger.warning("c")
os.chdir("." + delimeter + "User" + delimeter + str(k))
sp[ap.current_channel].save_token()
os.chdir(".." + delimeter + ".." + delimeter)
logger.warning("d")
result = "done: %s" % qs
return {'operation': op, 'result': result}