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


Python SNSLog.debug方法代码示例

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


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

示例1: reply

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import debug [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

示例2: _fetch_code_local_username_password

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import debug [as 别名]
    def _fetch_code_local_username_password(self):
        try:
            login_username = self.auth_info.login_username
            login_password = self.auth_info.login_password
            app_key = self.jsonconf.app_key
            app_secret = self.jsonconf.app_secret
            callback_url = self.auth_info.callback_url

            referer_url = self._last_requested_url

            postdata = {"client_id": app_key,
                        "redirect_uri": callback_url,
                        "userId": login_username,
                        "passwd": login_password,
                        "isLoginSina": "0",
                        "action": "submit",
                        "response_type": "code",
            }

            headers = {"User-Agent": "Mozilla/5.0 (Windows NT 6.1; rv:11.0) Gecko/20100101 Firefox/11.0",
                       "Host": "api.weibo.com",
                       "Referer": referer_url
            }

            auth_url = "https://api.weibo.com/oauth2/authorize"
            # auth_url = self.auth_info.auth_url
            resp_url = self._http_post(auth_url, data=postdata, headers=headers, json_parse=False).url
            logger.debug("response URL from local post: %s", resp_url)
            return resp_url
        except Exception, e:
            logger.warning("Catch exception: %s", e)
开发者ID:huiliang,项目名称:snsapi,代码行数:33,代码来源:sina.py

示例3: reply

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import debug [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

示例4: update_func

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import debug [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: _parse

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import debug [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

示例6: update

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import debug [as 别名]
    def update(self, text, title=None):
        '''
        Post a blog

        :param text: Blog post body.
        :param title: Blog post title. (optional)
        :return: success or not
        '''

        if title is None:
            title = self._cat(20, [(text, 1)])

        api_params = {'method': 'blog.addBlog',
                      'content': text,
                      'title': title}

        try:
            ret = self.renren_request(api_params)
            logger.debug("response: %s", ret)
            #TODO:
            #    Preserve the id for further use?
            #    Return it as multi-return-value?
            if 'id' in ret:
                logger.info("Update status '%s' on '%s' succeed", text, self.jsonconf.channel_name)
                return True
        except Exception, e:
            logger.warning("Catch Exception %s", e)
开发者ID:YangRonghai,项目名称:snsapi,代码行数:29,代码来源:renren.py

示例7: append

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import debug [as 别名]
 def append(self, e):
     if isinstance(e, Message):
         if hasattr(e, 'deleted') and e.deleted:
             logger.debug("Trying to append Deleted Message type element. Ignored")
         else:
             super(MessageList, self).append(e)
     else:
         logger.debug("Trying to append non- Message type element. Ignored")
开发者ID:Kelvin-Zhong,项目名称:snsapi,代码行数:10,代码来源:snstype.py

示例8: _parse

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import debug [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 'pic_urls' in dct:
            for pic in dct['pic_urls']:
                self.parsed.attachments.append({
                    'type':
                    'picture',
                    'format': ['link'],
                    'data':
                    pic['thumbnail_pic'].replace('/thumbnail/', '/woriginal/')
                })

        if 'retweeted_status' in dct:
            self.parsed.username_orig = "unknown"
            if 'pic_urls' in dct['retweeted_status']:
                for pic in dct['retweeted_status']['pic_urls']:
                    self.parsed.attachments.append({
                        'type':
                        'picture',
                        'format': ['link'],
                        'data':
                        pic['thumbnail_pic'].replace('/thumbnail/',
                                                     '/woriginal/')
                    })

            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:hurryhx,项目名称:snsapi,代码行数:60,代码来源:sina.py

示例9: auth

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import debug [as 别名]
    def auth(self):
        if self.get_saved_token():
            return

        logger.info("Try to authenticate '%s' using OAuth2", self.jsonconf.channel_name)
        self.auth_first()
        self.auth_second()
        self.save_token()
        logger.debug("Authorized! access token is " + str(self.token))
        logger.info("Channel '%s' is authorized", self.jsonconf.channel_name)
开发者ID:Nukker,项目名称:snsapi,代码行数:12,代码来源:renren.py

示例10: _parse

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import debug [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']
        # accordian to http://open.weibo.com/qa/index.php?qa=448&qa_1=v2-%E5%B7%B2%E6%94%B6%E8%97%8F%E5%BE%AE%E5%8D%9A-%E6%8E%A5%E5%8F%A3statuses-friends-timeline%E8%BF%94%E5%9B%9E%E5%AD%97%E6%AE%B5-favorited-%E4%B8%BAfalse
        # Currently we have no way to tell whether 
        # a weibo message is favorited Although there's a 
        # specious property
        self.parsed.liked = False
        if 'pic_urls' in dct:
            for pic in dct['pic_urls']:
                self.parsed.attachments.append(
                {
                    'type': 'picture',
                    'format': ['link'],
                    'data': pic['thumbnail_pic'].replace('/thumbnail/', '/woriginal/')
                })

        if 'retweeted_status' in dct:
            self.parsed.username_orig = "unknown"
            if 'pic_urls' in dct['retweeted_status']:
                for pic in dct['retweeted_status']['pic_urls']:
                    self.parsed.attachments.append(
                        {
                            'type': 'picture',
                            'format': ['link'],
                            'data': pic['thumbnail_pic'].replace('/thumbnail/', '/woriginal/')
                        })

            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:wcyz666,项目名称:snsrouter-modified,代码行数:57,代码来源:sina.py

示例11: _oauth2_second

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import debug [as 别名]
    def _oauth2_second(self):
        '''
        The second stage of oauth. 
        Fetch authenticated code. 
        '''
        self.__init_oauth2_client() 

        url = self.fetch_code() 
        if url == "(null)" :
            raise snserror.auth
        self.token = self.parseCode(url)
        self.token.update(self.auth_client.request_access_token(self.token.code))
        logger.debug("Authorized! access token is " + str(self.token))
        logger.info("Channel '%s' is authorized", self.jsonconf.channel_name)
开发者ID:qiyeboy,项目名称:snsapi,代码行数:16,代码来源:snsbase.py

示例12: home_timeline

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import debug [as 别名]
 def home_timeline(self, count=20):
     ret = snstype.MessageList()
     logger.debug("acquiring lock")
     self.dblock.acquire()
     try:
         conn = sqlite3.connect(self.sqlitefile)
         c = conn.cursor()
         c.execute("SELECT pickled_object FROM home_timeline ORDER BY time DESC LIMIT 0, %d" % (count,))
         p = c.fetchall()
         logger.info("%d messages read from database" % (len(p)))
         for i in p:
             ret.append(str2obj(str(i[0])))
     except Exception, e:
         logger.warning("Error while reading database: %s" % (str(e)))
开发者ID:Kelvin-Zhong,项目名称:snsapi,代码行数:16,代码来源:snspocket.py

示例13: _short_url_weibo

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import debug [as 别名]
 def _short_url_weibo(self, url):
     try:
         results = self.weibo_request("short_url/shorten", "GET", {"url_long": url})
         logger.debug("URL shortening response: %s", results)
         u = results["urls"][0]
         return u["url_short"]
         # Even for usable URL, it returns False?
         # if u['result'] == 'true':
         #    return u["url_short"]
         # else:
         #    logger.warning("Response short URL is not usable ('%s'). Fallback to original URL", u["url_short"])
         #    return url
     except Exception as e:
         logger.warning("Catch exception when shortening URL on SinaWeibo: '%s'", e)
         return url
开发者ID:rankun203,项目名称:snsapi,代码行数:17,代码来源:sina.py

示例14: add_channel

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import debug [as 别名]
    def add_channel(self, jsonconf):
        logger.debug(json.dumps(jsonconf))
        cname = jsonconf["channel_name"]

        if cname in self:
            logger.warning("Duplicate channel_name '%s'. Nothing happens to it. ", cname)
            return False

        try:
            p = getattr(platform, jsonconf["platform"])
            self[cname] = p(jsonconf)
            self.__method_routing(cname, SNSPocket.__default_mapping)
        except AttributeError:
            logger.warning("No such platform '%s'. Nothing happens to it. ", jsonconf["platform"])

        return True
开发者ID:brickgao,项目名称:snsapi,代码行数:18,代码来源:snspocket.py

示例15: _parse

# 需要导入模块: from snslog import SNSLog [as 别名]
# 或者: from snslog.SNSLog import debug [as 别名]
    def _parse(self, dct):
        #print dct 
        #logger.debug("%s", 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 
            #return snstype.DeletedMessage(dct)

        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']
        #if 'user' in dct:
        #    self.parsed.username = dct['user']['name']
        #    self.parsed.userid = dct['user']['id']
        #    logger.warning("Parsed one message with unknown 'user' for SinaWeiboStatusMessage")
        #else:
        #    self.parsed.username = "unknown"
        #    self.parsed.userid = "unknown"

        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:Nukker,项目名称:snsapi,代码行数:47,代码来源:sina.py


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