• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python thirdparty.thrift_client函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get_success_pay_activities

def get_success_pay_activities(restaurant_id):
    """
    获取指定餐厅的所有活动名称
    """
    activities = get_pay_activities_by_restaurant(restaurant_id)

    results = [{'activity_id': act[0],
                'activity_category_id': act[1],
                'activity_name': ''}
               for act in activities]

    for act in results:
        if act['activity_category_id'] == \
                SubsidyPayRecord.CATEGORY_FOOD_ACTIVITY:
            try:
                with thrift_client('ers') as ers:
                    act['activity_name'] =\
                        ers.get_food_activity(act['activity_id']).name
            except:
                act['activity_name'] = ''

        elif act['activity_category_id'] == \
                SubsidyPayRecord.CATEGORY_RESTAURANT_ACTIVITY:
            try:
                with thrift_client('ers') as ers:
                    act['activity_name'] = get_restaurant_activity_name(
                        ers.get_restaurant_activity(act['activity_id']))
            except:
                act['activity_name'] = ''

    return results
开发者ID:liuzelei,项目名称:walis,代码行数:31,代码来源:restaurant.py


示例2: get_all_city_ids

    def get_all_city_ids(self):
        if self._all_city_ids is None:
            if self._user_struct is None:
                self._user_struct = self.get_user_struct()
                # if city.admin
            user_city_ids = self._user_struct.city_ids
            if user_city_ids:
                self._all_city_ids = user_city_ids
                return user_city_ids
            # if region_group.admin
            if self._user_struct.region_group_ids:
                with thrift_client('ers') as ers:
                    region_groups = ers.mget_region_group(self._user_struct.region_group_ids)
                user_city_ids = list(set([region_group.city_id
                                          for region_group in region_groups]))
            # if region.admin
            if self._user_struct.region_ids:
                with thrift_client('ers') as ers:
                    regions = ers.mget_region(self._user_struct.region_ids)

                user_city_ids_by_region = [v.city_id for k,v in regions.iteritems()]
                user_city_ids = list(set(user_city_ids_by_region + user_city_ids))

            if user_city_ids:
                self._all_city_ids = user_city_ids
                return user_city_ids
        return self._all_city_ids
开发者ID:liuzelei,项目名称:walis,代码行数:27,代码来源:model.py


示例3: set_user_bank_card

def set_user_bank_card(activity_payments):
    restaurant_ids = [payment['restaurant_id']
                      for payment in activity_payments]

    with thrift_client('eus') as eus:
        bank_card_map = eus.mget_bankcard_by_restaurant(restaurant_ids)

    with thrift_client('ers') as ers:
        bank_card_map2 = ers.mget_restaurant_bankcard(restaurant_ids)

    for payment in activity_payments:
        payment['have_bank_card'] = False
        card_id = cardholder_name = ''
        user_bank_card = bank_card_map.get(payment['restaurant_id'])
        if user_bank_card is not None:
            card_id = user_bank_card.card_id
            cardholder_name = user_bank_card.cardholder_name
        else:
            user_bank_card2 = bank_card_map2.get(payment['restaurant_id'])
            if user_bank_card2 is not None:
                card_id = user_bank_card2.card_id
                cardholder_name = user_bank_card2.cardholder_name

        payment['card_id'] = card_id
        payment['cardholder_name'] = cardholder_name

    return activity_payments
开发者ID:liuzelei,项目名称:walis,代码行数:27,代码来源:pay.py


示例4: get_city_ids_or_restaurant_ids_by_user

def get_city_ids_or_restaurant_ids_by_user():
    """ return [city_ids,], [restaurant_ids] """
    user_id = current_user.id

    # if super admin
    if current_user.is_super_admin():
        return None, None

    with thrift_client('ers') as ers:
        user_struct = ers.get_direct_struct(user_id)

    # if city.admin
    if user_struct.city_ids:
        return user_struct.city_ids, None

    region_ids = []
    # if region_group.admin
    if user_struct.region_group_ids:
        with thrift_client('ers') as ers:
            regions = ers.get_regions_by_region_group_ids(
                user_struct.region_group_ids)
        region_ids = [region.id for region in regions]

    # if region.admin
    if user_struct.region_ids:
        region_ids.extend(user_struct.region_ids)
        region_ids = list(set(region_ids))

    with thrift_client('ers') as ers:
        restaurant_ids = ers.mget_restaurant_in_region(region_ids, True)

    return None, restaurant_ids
开发者ID:liuzelei,项目名称:walis,代码行数:32,代码来源:pay.py


示例5: get_restaurant_ids_in_charge

    def get_restaurant_ids_in_charge(self):
        # if super admin
        if self.is_super_admin():
            return None

        with thrift_client('ers') as ers:
            user_struct = ers.get_direct_struct(self.id)

        # if city.admin
        if user_struct.city_ids:
            return None

        region_ids = []
        # if region_group.admin
        if user_struct.region_group_ids:
            with thrift_client('ers') as ers:
                regions = ers.get_regions_by_region_group_ids(
                    user_struct.region_group_ids)
            region_ids = [region.id for region in regions]

        # if region.admin
        if user_struct.region_ids:
            region_ids.extend(user_struct.region_ids)
            region_ids = list(set(region_ids))

        with thrift_client('ers') as ers:
            restaurant_ids = ers.mget_restaurant_in_region(region_ids, True)

        return restaurant_ids
开发者ID:liuzelei,项目名称:walis,代码行数:29,代码来源:model.py


示例6: sget

    def sget(pk):
        city = city_base.get(pk)

        district_query = thirdparty_svc.ers.TDistrictQuery()
        district_query.city_id = city['id']
        district_query.is_valid = True
        with thrift_client('ers') as ers:
            districts = ers.query_district(district_query)
            districts = any_to_raw(districts)

        zone_query = thirdparty_svc.ers.TZoneQuery()
        zone_query.city_id = city['id']
        zone_query.is_valid = True
        with thrift_client('ers') as ers:
            zones = ers.query_zone(zone_query)
            zones = any_to_raw(zones)

        [_district.__setitem__('_zones', []) for _district in districts]
        districts_map = {district['id']: district for district in districts}
        for zone in zones:
            district = districts_map.get(zone['district_id'], None)
            if district:
                district['_zones'].append(zone)
        city['_districts'] = districts
        return city
开发者ID:liuzelei,项目名称:walis,代码行数:25,代码来源:city_manage.py


示例7: set_food_activity

def set_food_activity():
    """
    设置食物活动
    """
    restaurant_ids, category_ids, food_ids, restaurant_id, category_id, \
    food_id = parse_args1()
    _food_ids = copy.copy(food_ids)
    with thrift_client('ers') as ers:
        for _id in restaurant_ids:
            food_query = thirdparty_svc.ers.TFoodQuery()
            food_query.restaurant_id = _id
            food_query.is_valid = True
            food_query.limit = 1000
            foods = ers.query_food(food_query)
            _food_ids.extend([food.id for food in foods])
        for _id in category_ids:
            food_query = thirdparty_svc.ers.TFoodQuery()
            food_query.category_id = _id
            food_query.is_valid = True
            food_query.limit = 1000
            foods = ers.query_food(food_query)
            _food_ids.extend([food.id for food in foods])
    _food_ids = list(set(_food_ids))
    act_id = request.json.get('activity_id', None)
    weekdays = request.json.get('weekdays', [])
    with thrift_client('ers') as ers:
        if act_id:
            ers.add_food_activity(act_id, _food_ids, weekdays)
        else:
            ers.clear_food_activity(_food_ids, weekdays)
    return ''
开发者ID:liuzelei,项目名称:walis,代码行数:31,代码来源:menu.py


示例8: get_rst_not_in_charge

def get_rst_not_in_charge(user_id, rst_ids):
    region_struct = get_direct_struct(user_id)
    city_ids = set(getattr(region_struct, 'city_ids', []))
    region_ids = set(getattr(region_struct, 'region_ids', []))
    rg_ids = set(getattr(region_struct, 'region_group_ids', []))

    rst_to_clean = copy.copy(rst_ids)

    if city_ids:
        rsts = rst_base.mget(rst_ids)
        rst_to_clean = [rst.id for rst in rsts if rst.city_id not in city_ids]

    if rg_ids:
        with thrift_client('ers') as ers:
            ex_regions = ers.get_regions_by_region_group_ids(rg_ids)
            ex_region_ids = set([r.id for r in ex_regions])
        if ex_region_ids:
            region_ids |= ex_region_ids

    if not region_ids:
        return rst_to_clean

    with thrift_client('ers') as ers:
        rst_region_map = ers.get_restaurant_region_map(rst_to_clean)

    for rst_id, region_id in rst_region_map.items():
        if region_id in region_ids:
            rst_to_clean.remove(rst_id)

    return rst_to_clean
开发者ID:liuzelei,项目名称:walis,代码行数:30,代码来源:clean_rst_director.py


示例9: get

def get(food_id):
    food_id = int(food_id)
    # todo image_size未使用!
    image_size = request.args.get('image_size', None)
    with thrift_client('ers') as ers:
        food = ers.master_get_food(food_id)
        image_hash = food.image_hash
        image_path = ''
        if image_hash:
            with thrift_client('fuss') as fuss:
                image_path = fuss.file_get_sized(image_hash, image_size)
    return image_path
开发者ID:liuzelei,项目名称:walis,代码行数:12,代码来源:image.py


示例10: get_pending_activity_stats

def get_pending_activity_stats(args):
    """ get activity status which is pending """
    search_text = to_int(args.get('search_text'))
    query_city_id = to_int(args.get('city_id'))
    page_no, page_size = get_paging_params()
    user_city_ids, user_restaurant_ids = \
        get_city_ids_or_restaurant_ids_by_user()

    t_activity_status_query = thirdparty_svc.eos.TActivityStatsQuery()
    t_activity_status_query.statuses = [
        thirdparty_svc.eos.ActivityStatsConst.STATUS_PENDING, ]
    t_activity_status_query.with_subsidy = True
    t_activity_status_query.from_date = args.get('from_date')
    t_activity_status_query.to_date = args.get('to_date')
    t_activity_status_query.offset = (page_no - 1) * page_size
    t_activity_status_query.limit = page_size

    # if current_user is admin, restaurant_ids and user_city_ids are None.
    if current_user.is_super_admin():
        if query_city_id is not None:
            t_activity_status_query.city_ids = [query_city_id, ]
        if search_text is not None:
            t_activity_status_query.restaurant_ids = [search_text, ]
        with thrift_client('eos') as eos:
            activity_status_list = eos.query_auto_pay_activity_stats_result(
                t_activity_status_query)
        return [act.__dict__ for act in activity_status_list]

    if user_restaurant_ids or user_city_ids:
        city_ids = user_city_ids
        if query_city_id is not None:
            if user_city_ids is None or query_city_id in user_city_ids:
                city_ids = [query_city_id, ]
            else:
                return []
        t_activity_status_query.city_ids = city_ids

        # if user_city_ids is not None, user_restaurant_ids must be None
        restaurant_ids = user_restaurant_ids
        if search_text is not None:
            restaurant_ids = [search_text, ]
        t_activity_status_query.restaurant_ids = restaurant_ids

        with thrift_client('eos') as eos:
            activity_status_list = eos.query_auto_pay_activity_stats_result(
                t_activity_status_query)

        return [act.__dict__ for act in activity_status_list]

    else:
        return []
开发者ID:liuzelei,项目名称:walis,代码行数:51,代码来源:pay.py


示例11: get_suspicious_orders

 def get_suspicious_orders(cls, restaurant_id, date, **kwargs):
     query_kwargs = {
         'restaurant_id': restaurant_id,
         'date': date
     }
     result = zeus_query('eyes', 'walle_get_suspicious_orders',
                         thirdparty_svc.eyes.TWalleSuspiciousOrderQuery,
                         **query_kwargs)
     # for order in result:
     # order['id'] = order['_id']
     order_ids = [order['id'] for order in result]
     orders = OrderBase.mget(order_ids)
     orders = {order['id']: order for order in orders}
     with thrift_client('eos') as eos:
         orders_info = eos.mget_order_info(order_ids)
         orders_info = getresult_to_raw(orders_info)
     orders_info = {info['order_id']: info for info in orders_info}
     for order in result:
         order.update(orders[order['id']])
         order.update(orders_info[order['id']])
     for order in result:
         if order['phone_rating'] == 1:
             order['is_new_user'] = True
         else:
             order['is_new_user'] = False
     phones = [order['phone'] for order in orders.values()]
     phones_ban_status_map = {phone: PhoneBanBase.get_phone_ban_status(phone)
                              for phone in phones}
     user_ids = [order['user_id'] for order in orders.values()]
     with thrift_client('eus') as eus_client:
         users = eus_client.mget(user_ids)
         users = any_to_raw(users)
     users_map = {user['id']: user for user in users}
     for order in result:
         order['phone_ban_status'] = phones_ban_status_map[order['phone']]
         order['user_is_active'] = users_map[order['user_id']]['is_active']
     for order in result:
         try:
             better_json = json.loads(order['better_json'])
             better_json = flatten(better_json)
             subsidy = 0
             for _better_what in better_json:
                 price = _better_what.get('price', 0)
                 if price < 0:
                     subsidy += price
             order['subsidy'] = abs(subsidy)
             order['id'] = unicode(order['id'])
         except:
             continue
     return result
开发者ID:liuzelei,项目名称:walis,代码行数:50,代码来源:audit.py


示例12: get_user_struct

    def get_user_struct(self):
        if self._user_struct is None:
            with thrift_client('ers') as ers:
                self._user_struct = ers.get_direct_struct(self.id)

        region_ids = []
        if self._user_struct.region_group_ids:
            with thrift_client('ers') as ers:
                regions = ers.get_regions_by_region_group_ids(
                    self._user_struct.region_group_ids)
            region_ids = [region.id for region in regions]
        if region_ids:
            self._user_struct.region_ids.extend(region_ids)
        return self._user_struct
开发者ID:liuzelei,项目名称:walis,代码行数:14,代码来源:model.py


示例13: post_or_put

def post_or_put(activity_id=None):
    if activity_id is not None:
        activity_id = int(activity_id)
    activity_json = request.json
    with thrift_client('ers') as ers_client:
        if activity_id:
            with thrift_client('ers') as ers:
                activity = ers.get_restaurant_activity(activity_id)
            activity = _restaurant_activity_json2ttype(activity_json, activity)
            ers_client.update_restaurant_activity(activity_id, activity)
        else:
            activity = _restaurant_activity_json2ttype(activity_json)
            ers_client.add_restaurant_activity(activity)
        return ''
开发者ID:liuzelei,项目名称:walis,代码行数:14,代码来源:rst_activity.py


示例14: get_city_id_name_pairs_by_user

def get_city_id_name_pairs_by_user():
    # if super admin
    if current_user.is_super_admin():
        return {city.id: city.name for city in get_all_cities()}

    with thrift_client('ers') as ers:
        user_struct = ers.get_direct_struct(current_user.id)

    # if city.admin
    if user_struct.city_ids:
        with thrift_client('ers') as ers:
            cities = ers.mget_city(user_struct.city_ids).values()
        return {city.id: city.name for city in cities}

    # do not have cities
    return []
开发者ID:liuzelei,项目名称:walis,代码行数:16,代码来源:city.py


示例15: get

def get(id_or_ids):
    with thrift_client('ers') as ers:
        if isinstance(id_or_ids, (tuple, list)):
            result = ers.mget_food_activity(id_or_ids)
        else:
            result = ers.get_food_activity(id_or_ids)
    return result
开发者ID:liuzelei,项目名称:walis,代码行数:7,代码来源:food_activity.py


示例16: update_restaurant

def update_restaurant(rst_id, user_id, **rst_struct):
    rst = thirdparty_svc.ers.TRestaurant()
    for k, v in rst_struct.iteritems():
        if hasattr(rst, k):
            setattr(rst, k, v)
    with thrift_client('ers') as ers:
        ers.update_restaurant(rst_id, user_id, rst)
开发者ID:liuzelei,项目名称:walis,代码行数:7,代码来源:restaurant.py


示例17: query_restaurant

def query_restaurant(city_ids=None, region_ids=None, is_premium=False, is_valid=True, offset=None, limit=None):
    query = _create_restaurant_query(city_ids, region_ids, is_premium,
                                     is_valid, offset, limit)
    with thrift_client('ers') as ers:
        result = ers.search_filter_restaurant(query)
        rst_list = json.loads(result)['hits']
    return rst_list
开发者ID:liuzelei,项目名称:walis,代码行数:7,代码来源:restaurant.py


示例18: approval_payment

def approval_payment(payment_dict):
    restaurant_ids_set = set()
    [restaurant_ids_set.update(restaurant_ids) for restaurant_ids in
     payment_dict.values()]
    with thrift_client('eos') as eos:
        for restaurant_id in restaurant_ids_set:
            eos.generate_activity_subsidy_pay_record_new(restaurant_id)
开发者ID:liuzelei,项目名称:walis,代码行数:7,代码来源:pay.py


示例19: reject_payment

def reject_payment(payment_dict):
    restaurant_ids_set = set()
    [restaurant_ids_set.update(restaurant_ids) for restaurant_ids in
     payment_dict.values()]
    with thrift_client('eos') as eos:
        for restaurant_id in restaurant_ids_set:
            eos.doubt_activity_subsidy_stats_new(restaurant_id)
开发者ID:liuzelei,项目名称:walis,代码行数:7,代码来源:pay.py


示例20: is_banned

 def is_banned(cls, phone):
     with thrift_client('eos') as eos_client:
         result = eos_client.check_phones_in_blacklist([phone, ])
         if result:
             return cls.BLACK
         else:
             return cls.WHITE
开发者ID:liuzelei,项目名称:walis,代码行数:7,代码来源:audit.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python args_parser.parse函数代码示例发布时间:2022-05-26
下一篇:
Python models.Page类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap