Beispiel #1
0
def my_cj(stuid):
    collection = db.bxqcj
    one_bxqcj = {}
    one_bxqcj["stuid"] = stuid
    try:
        one_bxqcj["cj"] = get_bxqcj(stuid)
        if collection.update({"stuid": stuid}, {"$set": {"cj": one_bxqcj["cj"]}})["updatedExisting"]:
            pass
        else:
            collection.insert(one_bxqcj)
    except Exception as e:
        print "except:", repr(e)
    return one_bxqcj
Beispiel #2
0
def update_cj(stus):
    collection = db.bxqcj
    for stuid in stus:
        has_phone = db.phone.find_one({"stuid": stuid})
        if not has_phone:
            print "no phone num find"
            continue
        one_bxqcj = {}
        one_bxqcj["stuid"] = stuid
        try:
            one_bxqcj["cj"] = get_bxqcj(stuid)
            if collection.update({"stuid": stuid},
            {"$set": {"cj": one_bxqcj["cj"]}})["updatedExisting"]:
                pass
            else:
                collection.insert(one_bxqcj)
        except Exception as e:
            logger.info("except %s"%(repr(e)) )