コード例 #1
0
ファイル: queue.py プロジェクト: changguanghua/sina-automator
 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)
コード例 #2
0
ファイル: queue.py プロジェクト: hupili/sina-automator
 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)
コード例 #3
0
ファイル: score.py プロジェクト: Kelvin-Zhong/sns-router
 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()
コード例 #4
0
 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()
コード例 #5
0
ファイル: queue.py プロジェクト: fqj1994/sns-router
    def input(self, channel = None):
        if channel:
            ml = self._home_timeline(channel)
        else:
            ml = snstype.MessageList()
            for chn in self.sp:
                ml.extend(self._home_timeline(chn))

        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)
コード例 #6
0
    def input(self, channel=None):
        if channel:
            ml = self._home_timeline(channel)
        else:
            ml = snstype.MessageList()
            for chn in self.sp:
                ml.extend(self._home_timeline(chn))

        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)
        return "Input %s new messages" % count
コード例 #7
0
    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
        end = self.time()
        logger.info("Reweight done. Time elapsed: %.2f", end - begin)
        return True

    def _dump2pickle(self, fn_pickle):
        # dump all to pickle format
        cur = self.con.cursor()
        r = cur.execute('''
        SELECT id,time,userid,username,text,pyobj,flag FROM msg  
        ''')
        message_list = snstype.MessageList()
        for m in r:
            obj = self._str2pyobj(m[5])
            obj.msg_id = m[0]
            obj.flag = m[6]
            message_list.append(obj)
        r = cur.execute('''
コード例 #8
0
   * lc = load_config
   * sc = save_config
   * lsc = list_channel
   * lsp = list_platform
   * newc = new_channel
   * addc = add_channel
   * clc = clear_channel
   * auth = auth
   * ht = home_timeline
   * up = update
   * re = reply
   * fwd = forward
   * lk = like
   * ulk = unlike
   
Tutorial of SNSCLI:

   * https://github.com/hupili/snsapi/wiki/Tutorial-of-snscli
"""

if __name__ == '__main__':
    #==== default initialization one may like ====
    print helpdoc
    load_config()
    list_channel()
    auth()

    logger.info("Ready to drop into the interactive shell of SNSCLI!")
    import code
    code.interact(local=locals())
コード例 #9
0
 def load_weight(self, fn=None):
     if fn is None:
         fn = 'conf/weights.json'
     self.feature_weight = json.loads(open(fn, 'r').read())
     self.feature_name = self.feature_weight.keys()
     logger.info("Loaded weights: %s", self.feature_weight)
コード例 #10
0
ファイル: score.py プロジェクト: Kelvin-Zhong/sns-router
 def load_weight(self, fn = None):
     if fn is None:
         fn = 'conf/weights.json'
     self.feature_weight = json.loads(open(fn, 'r').read())
     self.feature_name = self.feature_weight.keys()
     logger.info("Loaded weights: %s", self.feature_weight)
コード例 #11
0
        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
        end = self.time()
        logger.info("Reweight done. Time elapsed: %.2f", end - begin)
        return True

    def _dump2pickle(self, fn_pickle):
        # dump all to pickle format
        cur = self.con.cursor()
        r = cur.execute('''
        SELECT id,time,userid,username,text,pyobj,flag FROM msg  
        ''')
        message_list = snstype.MessageList()
        for m in r:
            obj = self._str2pyobj(m[5])
            obj.msg_id = m[0]
            obj.flag = m[6]
            message_list.append(obj)
        r = cur.execute('''