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


Python leancloud.LeanCloudError方法代码示例

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


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

示例1: init_app

# 需要导入模块: import leancloud [as 别名]
# 或者: from leancloud import LeanCloudError [as 别名]
def init_app(app):
    app.config.update({'SECRET_KEY': const.SECRET_KEY})

    login_manager = LoginManager(app)
    login_manager.session_protection = 'basic'
    login_manager.login_view = 'auth.xauth'
    login_manager.refresh_view = 'auth.xauth'

    class FFAuth(Object):
        pass

    @login_manager.user_loader
    def load_user(user_id):
        try:
            return FFAuth.query.get(user_id)
        except LeanCloudError as _:
            pass
        return None

    app.register_blueprint(main_view)
    app.register_blueprint(auth_view) 
开发者ID:simpleapples,项目名称:fanfou-10th-anniversary,代码行数:23,代码来源:app.py

示例2: save_proxy_item

# 需要导入模块: import leancloud [as 别名]
# 或者: from leancloud import LeanCloudError [as 别名]
def save_proxy_item(url, count, tb1, tb2):
    item = Proxy_Item()
    urls = []
    for i in range(1, 10):
        urls.append(url % i)
    print urls
    item.set('urls', urls)
    item.set('xp_count', count)
    item.set('xp_tb1', tb1)
    item.set('xp_tb2', tb2)
    item.set('host', url)
    query = Query(Proxy_Item)
    try:
        if query.equal_to('host', url).first() is not None:
            print '??? Host'
    except leancloud.LeanCloudError:
        item.save() 
开发者ID:xcc3641,项目名称:Leancloud_imxie_cloud,代码行数:19,代码来源:model.py

示例3: show_post

# 需要导入模块: import leancloud [as 别名]
# 或者: from leancloud import LeanCloudError [as 别名]
def show_post(post_id):
    try:
        post = Post.query.get(post_id)
        if post.get('trashed'):
            abort(410)
        tags = get_tags_by_post(post)
    except LeanCloudError as e:
        if e.code == 101:
            abort(404)
        else:
            raise e
    post = markup(post)
    return render_template("post.html", post=post, tags=tags) 
开发者ID:nervouna,项目名称:Cuneiform,代码行数:15,代码来源:__init__.py

示例4: get_tag_by_name

# 需要导入模块: import leancloud [as 别名]
# 或者: from leancloud import LeanCloudError [as 别名]
def get_tag_by_name(tag_name, auto_create=True):
    try:
        tag = Tag.query.equal_to('name', tag_name).first()
    except LeanCloudError as e:
        if e.code == 101:
            if auto_create == True:
                tag = Tag()
                tag.set('name', tag_name)
                tag.save()
            else:
                tag = None
        else:
            raise e
    return tag 
开发者ID:nervouna,项目名称:Cuneiform,代码行数:16,代码来源:tag.py

示例5: get_a_page_of_log

# 需要导入模块: import leancloud [as 别名]
# 或者: from leancloud import LeanCloudError [as 别名]
def get_a_page_of_log(self, page, request_date):
        """
        ??????
        :param page: ??
        :param request_date: ?????? %Y%M%D?
        :return:
        """
        obj = leancloud.Object.extend('ilog_' + request_date)
        query = obj.query
        query.limit(10)
        query.skip((page - 1) * 10)
        query.add_descending("request_time")

        try:
            total_count = query.count()
            total_page = int(total_count / 10) + (1 if total_count % 10 else 0)

            objs = query.find()
            datas = [
                {
                    "request_url": obj.get('request_url'),
                    "request_param": obj.get('request_param'),
                    "response_data": obj.get('response_data'),
                    "request_time": obj.get('request_time'),
                    "use_time": obj.get('use_time'),
                    "request_method": obj.get('request_method'),
                    "request_headers": obj.get('request_headers'),
                    "error_data": obj.get('error_data'),
                    "status_code": obj.get('status_code'),
                    "app_name": obj.get('app_name'),
                }
                for obj in objs
                ]
            return datas, total_page
        except leancloud.LeanCloudError:
            return [], 1 
开发者ID:yubang,项目名称:ilog,代码行数:38,代码来源:lc.py

示例6: get_a_page_of_program_log

# 需要导入模块: import leancloud [as 别名]
# 或者: from leancloud import LeanCloudError [as 别名]
def get_a_page_of_program_log(self, page, request_date, level):
        """
        ??????????
        :param page: ??
        :param request_date: ?????? %Y%M%D?
        :param level: ????
        :return:
        """
        obj = leancloud.Object.extend('ilog_program_' + request_date)
        query = obj.query
        query.limit(10)
        query.skip((page - 1) * 10)
        query.add_descending("log_time")

        if level != 'all':
            query.equal_to("level", level)

        try:
            total_count = query.count()
            total_page = int(total_count / 10) + (1 if total_count % 10 else 0)

            objs = query.find()
            datas = [
                {
                    "level": obj.get('level'),
                    "msg": obj.get('msg'),
                    "log_time": obj.get('log_time'),
                    "app_name": obj.get('app_name'),
                }
                for obj in objs
                ]
            return datas, total_page
        except leancloud.LeanCloudError:
            return [], 1 
开发者ID:yubang,项目名称:ilog,代码行数:36,代码来源:lc.py

示例7: oauth_verify

# 需要导入模块: import leancloud [as 别名]
# 或者: from leancloud import LeanCloudError [as 别名]
def oauth_verify():
    try:
        req = session['req']
        o = OAuth1Session(const.CONSUMER_KEY, const.CONSUMER_SECRET,
                          req['oauth_token'],
                          req['oauth_token_secret'], verifier=req['oauth_token'])
        ac = o.fetch_access_token("http://fanfou.com/oauth/access_token")
        session['req'] = ac
        user = o.get("http://api.fanfou.com/account/verify_credentials.json?mode=lite").json()
    except:
        session['error_msg'] = "?????????"
        return redirect(url_for('.xauth'))

    try:
        try:
            ff_auth = FFAuth.query.equal_to('uniqueID', user['unique_id']).first()
        except LeanCloudError as err:
            if err.code == 101:
                ff_auth = FFAuth()
        ff_auth.set('username', user['id'])
        ff_auth.set('nickname', user['name'])
        ff_auth.set('uniqueID', user['unique_id'])
        ff_auth.set('token', ac['oauth_token'])
        ff_auth.set('secret', ac['oauth_token_secret'])
        ff_auth.save()
    except LeanCloudError:
        session['error_msg'] = "????????"
        return redirect(url_for('.xauth'))
    login_user(ff_auth, True)
    return redirect(url_for('main.index')) 
开发者ID:simpleapples,项目名称:fanfou-10th-anniversary,代码行数:32,代码来源:auth.py

示例8: show

# 需要导入模块: import leancloud [as 别名]
# 或者: from leancloud import LeanCloudError [as 别名]
def show():
    try:
        todos = Query(Todo).descending('createdAt').find()
    except LeanCloudError, e:
        if e.code == 101:  # ?????? Class ????
            todos = []
        else:
            raise e
    return render_template('todos.html', todos=todos) 
开发者ID:xcc3641,项目名称:Leancloud_imxie_cloud,代码行数:11,代码来源:todos.py

示例9: handle_detail_msg

# 需要导入模块: import leancloud [as 别名]
# 或者: from leancloud import LeanCloudError [as 别名]
def handle_detail_msg(comment_type, meta_obj, response_obj):
    '''
    :param meta_obj: meta??
    :return: ??????????
    '''
    global CHAT_ID
    if CHAT_ID is None:
        query = TGChat.query
        query.equal_to('telegram_flag', 'Doublemine')
        try:
            query_result = query.first()
        except LeanCloudError:
            leancloud.logger.info('????????????CHAT_ID,?????????')
            return
        if query_result is not None and query_result.get('chat_id') is not None:
            CHAT_ID = query_result.get('chat_id')
        else:
            leancloud.logger.info('????????????CHAT_ID,?????????')
            return

    if meta_obj is not None:  # detail info
        print(meta_obj)
        telegram_push_str = "\t\t????%s\n\n" \
                            "????:\t %s\n\n" \
                            "????:\t %s\n\n" \
                            "ip??:\t %s\n\n" \
                            "????:\t %s\n\n" \
                            "????:\t %s\n\n" \
                            "????:\t %s" % (comment_type,
                                            meta_obj.get('author_name'),
                                            str(parse(meta_obj.get("agent"))),
                                            meta_obj.get('ip'),
                                            time.strftime("%Y-%m-%d %H:%M:%S",
                                                          time.localtime(int(response_obj.get("date")))),
                                            meta_obj.get('message'),
                                            HOST_NAME +
                                            meta_obj.get('thread_key'))
        print(telegram_push_str)
        try:
            BOT.sendMessage(chat_id=CHAT_ID, text=telegram_push_str, parse_mode=telegram.ParseMode.HTML,
                            disable_web_page_preview=False
                            )
        except telegram.error.BadRequest:
            leancloud.logger.error("????????????HTML5????MD??????")
            try:
                BOT.sendMessage(chat_id=CHAT_ID, text=telegram_push_str, parse_mode=telegram.ParseMode.MARKDOWN,
                                disable_web_page_preview=False
                                )
            except telegram.error.BadRequest:
                leancloud.logger.error("????????????MD????TEXT??")
                BOT.sendMessage(chat_id=CHAT_ID, text=telegram_push_str,
                                disable_web_page_preview=False
                                ) 
开发者ID:Doublemine,项目名称:TelegramBot,代码行数:55,代码来源:app.py

示例10: xauth

# 需要导入模块: import leancloud [as 别名]
# 或者: from leancloud import LeanCloudError [as 别名]
def xauth():
    form = AuthForm()
    if request.method == 'POST':
        if form.validate_on_submit():
            username = form.username.data
            password = form.password.data

            try:
                consumer = {'key': const.CONSUMER_KEY,
                            'secret': const.CONSUMER_SECRET}
                client = fanfou.XAuth(consumer, username, password)
                user_info = client.request('/users/show', 'POST')
                user_json = json.loads(user_info.read().decode('utf8'))
                nickname = user_json['screen_name']
                unique_id = user_json['unique_id']
                try:
                    ff_auth = FFAuth.query.equal_to('uniqueID', unique_id).first()
                except LeanCloudError as err:
                    if err.code == 101:
                        ff_auth = FFAuth()
                    else:
                        raise err
                token = client.oauth_token['key'].decode('utf-8')
                secret = client.oauth_token['secret'].decode('utf-8')
                ff_auth.set('uniqueID', unique_id)
                ff_auth.set('username', username)
                ff_auth.set('nickname', nickname)
                ff_auth.set('token', token)
                ff_auth.set('secret', secret)
                ff_auth.save()
                login_user(ff_auth, True)
                return redirect(url_for('main.index'))
            except LeanCloudError as _:
                error = '???????'
            except urllib.error.HTTPError as _:
                error = '????, ????????????'
        else:
            error = '????'
    else:
        error = session.get('error_msg', None)
        session['error_msg'] = None
    return render_template('auth.html',
                           form=form,
                           error=error) 
开发者ID:simpleapples,项目名称:fanfou-10th-anniversary,代码行数:46,代码来源:auth.py


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