Exemple #1
0
 def tag_user(self):
     self.valid_list = [
         ('cate_codes', '标签'), ('userids' ,'商户ID'), ('status', '状态')
     ]
     values = self.build_args()
     with get_connection_exception('qf_user') as db:
         cate_map_list = db.select(
             fields = ['cate_code', 'cate_name', 'remark'],
             table = 'user_category',
             where = {'userid': TagDef.VIRTUAL_USER_ID}
         )
         cate_map = {i['cate_code']: (i['cate_name'], i['remark'])
                 for i in cate_map_list}
     categories = []
     for userid in values['userids']:
         for cate_code in values['cate_codes']:
             tmp = UserCate(
                 code = cate_code,
                 name = unicode_to_utf8(cate_map.get(cate_code, ('', ''))[0]),
                 status = values['status'],
                 ctime = datetime.datetime.now().strftime(DATETIME_FMT),
                 remark = unicode_to_utf8(cate_map.get(cate_code, ('', ''))[1]),
             )
             categories.append(tmp)
     ret = thrift_callex(config.APOLLO_SERVERS, ApolloServer, 'setUsersCategory',
             list(values['userids']), categories)
     if ret != 0:
         raise ParamError('内部错误')
     return self.write(success({}))
Exemple #2
0
def load_config(args):
    config = util.unicode_to_utf8(
        json.load(open('%s.json' % args.model_path, 'rb')))
    for key, value in args.__args.items():
        try:
            config[key] = value.value
        except:
            config[key] = value

    return config