当前位置: 首页>>代码示例>>Python>>正文


Python snslog.SNSLog类代码示例

本文整理汇总了Python中snsapi.snslog.SNSLog的典型用法代码示例。如果您正苦于以下问题:Python SNSLog类的具体用法?Python SNSLog怎么用?Python SNSLog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SNSLog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 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 = {}
开发者ID:wcyz666,项目名称:snsrouter-modified,代码行数:31,代码来源:srfequeue.py

示例2: wrapper_check_login

 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)
开发者ID:wcyz666,项目名称:snsrouter-modified,代码行数:7,代码来源:srfe.py

示例3: config

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}
开发者ID:wcyz666,项目名称:snsrouter-modified,代码行数:33,代码来源:srfe.py

示例4: input

 def input(self, ml):
     count = 0 
     for m in ml:
         if self._inqueue(m):
             count += 1
     logger.info("Input %d new message", count)
     self.log("Input %d new message" % count)
开发者ID:changguanghua,项目名称:sina-automator,代码行数:7,代码来源:queue.py

示例5: select_samples

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
开发者ID:wcyz666,项目名称:snsrouter-modified,代码行数:28,代码来源:select_samples.py

示例6: run

 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)
开发者ID:fqj1994,项目名称:sns-router,代码行数:8,代码来源:srfe.py

示例7: tag_add

 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()
开发者ID:fqj1994,项目名称:sns-router,代码行数:8,代码来源:queue.py

示例8: __init__

    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 = {}
开发者ID:fqj1994,项目名称:sns-router,代码行数:9,代码来源:queue.py

示例9: rand_execute

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)
开发者ID:changguanghua,项目名称:sina-automator,代码行数:9,代码来源:butils.py

示例10: tag_toggle

 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)
开发者ID:wcyz666,项目名称:snsrouter-modified,代码行数:9,代码来源:srfequeue.py

示例11: config_preference_add

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!"
开发者ID:wcyz666,项目名称:snsrouter-modified,代码行数:10,代码来源:srfe.py

示例12: hook_new_message

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)
开发者ID:Kelvin-Zhong,项目名称:sns-router,代码行数:11,代码来源:hooks.py

示例13: load_weight

 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()
开发者ID:Kelvin-Zhong,项目名称:sns-router,代码行数:11,代码来源:score.py

示例14: home_timeline

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')}
开发者ID:wcyz666,项目名称:snsrouter-modified,代码行数:13,代码来源:srfe.py

示例15: run

 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)
开发者ID:wcyz666,项目名称:snsrouter-modified,代码行数:13,代码来源:srfe.py


注:本文中的snsapi.snslog.SNSLog类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。