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


Python SNSLog.warning方法代码示例

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


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

示例1: update

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import warning [as 别名]
 def update(self, text):
     try:
         self.client.miniblog.new(text)
         return True
     except Exception, e:
         logger.warning("DoubanAPIError: %s", e)
         return False
开发者ID:huiliang,项目名称:snsapi,代码行数:9,代码来源:douban.py

示例2: reply

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import warning [as 别名]
 def reply(self, statusId, text):
     res = None
     flag = False
     try:
         # The order in the bracket is important since there
         # exists "SHARE_XXXX" type. In order to figure out
         # the actual type, SHARE must be put in the first position.
         for msg_type in ["SHARE", "BLOG", "PHOTO", "ALBUM", "STATUS", "VIDEO"]:
             if msg_type in statusId.feed_type:
                 flag = True
                 break
         if flag:
             res = self.renren_request(
                 method="comment/put",
                 content=text,
                 commentType=msg_type,
                 entryOwnerId=statusId.source_user_id,
                 entryId=statusId.resource_id
             )
         else:
             return BooleanWrappedData(False, {
                 'errors': ['SNSAPI_NOT_SUPPORTED'],
             })
     except Exception, e:
         logger.warning('Catch exception: %s', e)
         return BooleanWrappedData(False, {
             'errors': ['PLATFORM_'],
         })
开发者ID:huiliang,项目名称:snsapi,代码行数:30,代码来源:renren.py

示例3: unlike

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import warning [as 别名]
 def unlike(self, message):
     res = None
     flag = False
     try:
         # The order in the bracket is important since there
         # exists "SHARE_XXXX" type. In order to figure out
         # the actual type, SHARE must be put in the first position.
         for msg_type in ["SHARE", "BLOG", "PHOTO", "ALBUM", "STATUS", "VIDEO"]:
             if msg_type in message.ID.feed_type:
                 flag = True
                 break
         if flag:
             res = self.renren_request(
                 method="like/ugc/remove",
                 ugcOwnerId=message.ID.source_user_id,
                 likeUGCType="TYPE_" + msg_type,
                 ugcId=message.ID.resource_id
             )
         else:
             return False
     except Exception as e:
         logger.warning('Catch exception: %s', type(e))
         return False
     if res:
         return True
     else:
         return False
开发者ID:huiliang,项目名称:snsapi,代码行数:29,代码来源:renren.py

示例4: update_func

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import warning [as 别名]
 def update_func(self):
     logger.debug("acquiring lock")
     self.dblock.acquire()
     try:
         conn = sqlite3.connect(self.sqlitefile)
         conn.row_factory = sqlite3.Row
         cursor = conn.cursor()
         cursor.execute("SELECT * FROM pending_update")
         i = cursor.fetchone()
         if i:
             cursor.execute("DELETE FROM pending_update WHERE id = ?", (i['id'], ))
             j = {
                 'id': str(i['id']),
                 'args': str2obj(str(i['args'])),
                 'kwargs': str2obj(str(i['kwargs'])),
                 'type': str(i['type']),
                 'callback': str2obj(str(i['callback']))
             }
             res = getattr(self.sp, j['type'])(*j['args'], **j['kwargs'])
             if j['callback']:
                 j['callback'](self, res)
         conn.commit()
         cursor.close()
     except Exception, e:
         logger.warning("Error while updating: %s" % (str(e)))
开发者ID:Kelvin-Zhong,项目名称:snsapi,代码行数:27,代码来源:snspocket.py

示例5: get

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import warning [as 别名]
    def get(self, attr, default_value = "(null)"):
        '''
        dict entry reading with fault tolerance. 

        :attr:
            A str or a list of str. 

        If attr is a list, we will try all the candidates until 
        one 'get' is successful. If none of the candidates succeed,
        we will return a "(null)"

        e.g. RSS format is very diverse. 
        To my current knowledge, some formats have 'author' fields, 
        but others do not:
           * rss : no
           * rss2 : yes
           * atom : yes
           * rdf : yes
        This function will return a string "(null)" by default if the 
        field does not exist. The purpose is to expose unified interface
        to upper layers. seeing "(null)" is better than catching an error. 

        '''
        if isinstance(attr, str):
            return dict.get(self, attr, default_value)
        elif isinstance(attr, list):
            for a in attr:
                val = dict.get(self, a, None)
                if val:
                    return val
            return default_value
        else:
            logger.warning("Unkown type: %s", type(attr))
            return default_value
开发者ID:Nukker,项目名称:snsapi,代码行数:36,代码来源:utils.py

示例6: reply

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import warning [as 别名]
    def reply(self, mID, text):
        '''
        Reply a renren blog

        :param mID: MessageID object
        :param text: string, the reply message
        :return: success or not
        '''

        if mID.user_type == 'user':
            owner_key = 'uid'
            owner_value = mID.source_user_id
        else:  # 'page'
            owner_key = 'page_id'
            owner_value = mID.source_page_id

        api_params = {'method': 'blog.addComment',
                      'content': text,
                      'id': mID.blog_id,
                      owner_key: owner_value}

        logger.debug('request parameters: %s', api_params)

        try:
            ret = self.renren_request(api_params)
            if 'result' in ret and ret['result'] == 1:
                logger.info("Reply '%s' to status '%s' succeed", text, mID)
                return True
        except Exception, e:
            logger.warning("Catch Exception %s", e)
开发者ID:YangRonghai,项目名称:snsapi,代码行数:32,代码来源:renren.py

示例7: unlike

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import warning [as 别名]
 def unlike(self, message):
     '''
     Unlike method
        * Weibo doesn't provide an API for "unlike"
        * So "unfavourite" function supersedes "unlike"
        * Here "unlike" means "remove from my favourites"
        * Receive a message
     '''
     mID = message.ID
     try:
         ret = self.weibo_request('favorites/destroy',
                 'POST',
                 {'id': mID.id})
         # error_code 20705 means this status had never been collected.
         # For the purpose of backward compatibility, we also view
         # it as a successful unlike
         if 'favorited_time' in ret or ret["error_code"] == 20705:
             return True
         else:
             logger.warning("'%s' unlikes status '%s' fail. ret: %s",
                     self.jsonconf.channel_name, mID, ret)
             return False
     except Exception, e:
         logger.warning("'%s' unlike status '%s' fail. ret: %s",
                     self.jsonconf.channel_name, mID, ret)
         return False
开发者ID:huiliang,项目名称:snsapi,代码行数:28,代码来源:sina.py

示例8: _parse

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import warning [as 别名]
    def _parse(self, dct):
        if "deleted" in dct and dct["deleted"]:
            logger.debug("This is a deleted message %s of SinaWeiboStatusMessage", dct["id"])
            self.parsed.time = "unknown"
            self.parsed.username = "unknown"
            self.parsed.userid = "unknown"
            self.parsed.text = "unknown"
            self.deleted = True
            return

        self.ID.id = dct["id"]

        self.parsed.time = utils.str2utc(dct["created_at"])
        self.parsed.username = dct["user"]["name"]
        self.parsed.userid = dct["user"]["id"]
        self.parsed.reposts_count = dct["reposts_count"]
        self.parsed.comments_count = dct["comments_count"]

        if "retweeted_status" in dct:
            self.parsed.username_orig = "unknown"
            try:
                self.parsed.username_orig = dct["retweeted_status"]["user"]["name"]
            except KeyError:
                logger.warning("KeyError when parsing SinaWeiboStatus. May be deleted original message")
            self.parsed.text_orig = dct["retweeted_status"]["text"]
            self.parsed.text_trace = dct["text"]
            self.parsed.text = (
                self.parsed.text_trace + " || " + "@" + self.parsed.username_orig + " : " + self.parsed.text_orig
            )
        else:
            self.parsed.text_orig = dct["text"]
            self.parsed.text_trace = None
            self.parsed.text = self.parsed.text_orig
开发者ID:rankun203,项目名称:snsapi,代码行数:35,代码来源:sina.py

示例9: _forward

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import warning [as 别名]
    def _forward(self, mID, text):
        """
        Raw forward method

           * Only support Sina message
           * Use 'text' as exact comment sequence
        """
        try:
            ret = self.weibo_request("statuses/repost", "POST", {"id": mID.id, "status": text})
            if "id" in ret:
                return True
            else:
                logger.warning(
                    "'%s' forward status '%s' with comment '%s' fail. ret: %s",
                    self.jsonconf.channel_name,
                    mID,
                    text,
                    ret,
                )
                return False
        except Exception as e:
            logger.warning(
                "'%s' forward status '%s' with comment '%s' fail: %s", self.jsonconf.channel_name, mID, text, e
            )
            return False
开发者ID:rankun203,项目名称:snsapi,代码行数:27,代码来源:sina.py

示例10: reply

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import warning [as 别名]
    def reply(self, statusID, text):
        '''
        docstring placeholder
        '''

        """reply status

           * parameter status: StatusID object
           * paramter text: string, the reply message
           * return: success or not
        """

        api_params = dict(method = "share.addComment", content = text, \
            share_id = statusID.status_id, user_id = statusID.source_user_id)

        try:
            ret = self.renren_request(api_params)
            logger.debug("Reply to status '%s' return: %s", statusID, ret)
            if 'result' in ret and ret['result'] == 1:
                logger.info("Reply '%s' to status '%s' succeed", text, statusID)
                return True
            else:
                return False
        except Exception, e:
            logger.warning("Reply failed: %s", e)
开发者ID:uestcmy,项目名称:snsapi_changedfile,代码行数:27,代码来源:renren.py

示例11: home_timeline

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import warning [as 别名]
    def home_timeline(self, count=20):
        '''Get home timeline

            * function : get statuses of yours and your friends'
            * parameter count: number of statuses
        '''
        url = "https://api.weibo.com/2/statuses/home_timeline.json"
        params = {}
        params['count'] = count
        params['access_token'] = self.token.access_token
        
        jsonobj = self._http_get(url, params)
        
        statuslist = snstype.MessageList()
        try:
            if("error" in  jsonobj):
                logger.warning("error json object returned: %s", jsonobj)
                return []
            for j in jsonobj['statuses']:
                statuslist.append(self.Message(j,\
                        platform = self.jsonconf['platform'],\
                        channel = self.jsonconf['channel_name']\
                        ))
        except Exception, e:
            logger.warning("Catch exception: %s", e)
开发者ID:uestcmy,项目名称:snsapi_changedfile,代码行数:27,代码来源:sina.py

示例12: forward

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import warning [as 别名]
 def forward(self, message, text):
     try:
         self.client.miniblog.reshare(message.ID.id)
         return True
     except Exception, e:
         logger.warning("DoubanAPIError: %s", e)
         return False
开发者ID:huiliang,项目名称:snsapi,代码行数:9,代码来源:douban.py

示例13: unlike

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import warning [as 别名]
 def unlike(self, message):
     try:
         self.client.miniblog.unlike(message.ID.id)
         return True
     except Exception, e:
         logger.warning("DoubanAPIError, %s", e)
         return False
开发者ID:huiliang,项目名称:snsapi,代码行数:9,代码来源:douban.py

示例14: reply

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import warning [as 别名]
 def reply(self, statusID, text):
     try:
         self.client.miniblog.comment.new(statusID.id, text)
         return True
     except Exception, e:
         logger.warning('DoubanAPIError: %s', str(e))
         return False
开发者ID:huiliang,项目名称:snsapi,代码行数:9,代码来源:douban.py

示例15: _forward

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import warning [as 别名]
    def _forward(self, mID, text):
        '''
        Raw forward method

           * Only support Renren message
           * Use 'text' as exact comment sequence
        '''
        try:
            api_params = {'method': 'status.forward',
                    'status': text,
                    'forward_owner': mID.source_user_id,
                    'place_id': 'RRAF04D95FA37892FFA88',
                    'forward_id': mID.status_id
                    }
            ret = self.renren_request(api_params)
            if 'id' in ret:
                # ret['id'] is the ID of new status
                # X, their doc says the field name is 'result'...
                return True
            else:
                logger.warning("'%s' forward status '%s' with comment '%s' fail. ret: %s",
                        self.jsonconf.channel_name, mID, text, ret)
                return False
        except Exception as e:
            logger.warning("'%s' forward status '%s' with comment '%s' fail: %s",
                    self.jsonconf.channel_name, mID, text, e)
            return False
开发者ID:YangRonghai,项目名称:snsapi,代码行数:29,代码来源:renren.py


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