示例#1
0
def web_get_api(db, env, arg):
    apiId = arg["paras"].get('id')
    if not apiId:
        return buildRetObj(SEGMENT_NOT_EXIST, None)

    api = getApi(db, apiId)
    if (not api):
        return buildRetObj(SEGMENT_NOT_EXIST, None)

    return buildRetObj(OCT_SUCCESS, api.toObj())
示例#2
0
def web_logout(db, env, arg):
    sessionId = arg.get("centerSessionID")
    if not sessionId:
        ERROR("no session uuid to logout %s" % str(arg))
        return buildRetObj(OCT_SUCCESS)

    session = getSession(db, sessionId)
    if not session:
        ERROR("get session error to logout %s" % sessionId)
        return buildRetObj(OCT_SUCCESS)

    return buildRetObj(OCT_SUCCESS)
示例#3
0
def web_login(db, env, arg):
    paras = arg["paras"]
    user = userService.getUserByName(db, paras.get("account"))
    if (not user):
        return buildRetObj(USER_NOT_EXIST, None)

    ret = user.auth(b64_decode(paras.get("password")))
    if ret == 0:
        data = {"id": user.myId, "name": user.name, "role": user.role}
        sessionObj = newSession(db, data)
        data["session"] = sessionObj
        return buildRetObj(OCT_SUCCESS, data)
    else:
        return buildRetObj(USER_PASSWD_ERR)
示例#4
0
def web_logout(db, env, arg):

    paras = arg["paras"]
    sessionId = paras.get("sessionUuid")
    removeSession(db, sessionId)

    return buildRetObj(OCT_SUCCESS)
示例#5
0
def doServerDispatching(arg, API_LIST):
    apiProto = API_LIST.get(arg.get("api"))
    if (not apiProto):
        ERROR("func of %s not exist" % arg.get("api"))
        return buildRetObj(SEGMENT_NOT_EXIST)

    ret, errorMsg = checkParas(arg.get("paras"), apiProto)
    if (not ret):
        ERROR("check paras error [%s]" % errorMsg)
        return buildRetObj(INVALID_PARAS, errorLog=errorMsg)

    arg["async"] = False  # TBD

    if (arg.get("async")):
        return writeServerApi(arg, apiProto)
    else:
        return callServerWebServiceDir(apiProto["func"], arg, apiProto)
示例#6
0
def web_get_user(db, env, arg):
    userId = arg["paras"].get("id")
    if userId == None:
        ret, data = userService.get_alluser(db, arg)
    else:
        ret, data = userService.get_user(db, userId)

    return buildRetObj(ret, data)
示例#7
0
def web_ukeylogin(db, env, arg):
    user = userService.getUserByUkey(db, str(arg["paras"].get("ukey")))
    if (not user):
        return buildRetObj(USER_NOT_EXIST, None)

    ret = user.authUkey(arg["paras"].get("ukey"))
    if ret == 0:
        data = {
            'id': user.uid,
            'ukey': user.ukey,
            'name': user.name,
            'role': user.role
        }
        return buildRetObj(OCT_SUCCESS, data)

    elif ret == -2:
        return buildRetObj(USER_PASSWD_ERR)

    else:
        return buildRetObj(DB_ERR)
示例#8
0
文件: dispatch.py 项目: maqg/wcrobot
def doDispatching(arg, session, API_LIST):
    apiProto = API_LIST.get(arg.get("api"))
    if (not apiProto):
        ERROR("func of %s not exist" % arg.get("api"))
        return buildRetObj(SEGMENT_NOT_EXIST)

    ret, errorMsg = checkParas(arg.get("paras"), apiProto)
    if (not ret):
        ERROR("check paras error [%s]" % errorMsg)
        return buildRetObj(UNACCP_PARAS, errorLog=errorMsg)

    ret, errorMsg = checkRoles(arg.get("paras"), apiProto)
    if (not ret):
        ERROR("check roles error [%s]" % errorMsg)
        return buildRetObj(PERMISSION_NOT_ENOUGH, errorLog=errorMsg)

    arg["async"] = False  # TBD

    if (arg.get("async")):
        return writeApi(arg, session, apiProto)
    else:
        return callWebServiceDir(apiProto["func"], session, arg, apiProto)
示例#9
0
文件: TUNDRA.py 项目: maqg/tundra
    def post(self):

        try:
            file_metas = self.request.files["file"]
        except:
            file_metas = self.request.files["filename"]

        fileName = file_metas[0].get("filename") or "unknown"
        if isSystemWindows():
            filePath = "var/tmp/" + fileName + ".XXXX" + getUuid()
        else:
            filePath = "/tmp/" + fileName + ".XXXX" + getUuid()

        for meta in file_metas:
            with open(filePath, 'wb') as up:
                up.write(meta['body'])

        retObj = buildRetObj(OCT_SUCCESS, data=filePath)
        self.write(buildReply(retObj))
        self.finish()
示例#10
0
def web_logout(db, env, arg):
    ret, data = robotService.logout_robot(db, arg)
    return buildRetObj(ret, data)
示例#11
0
def web_update_robot(db, env, arg):
    ret = robotService.update_robot(db, arg)
    return buildRetObj(ret)
示例#12
0
def web_add_robot(db, env, arg):
    ret = robotService.add_robot(db, env, arg)
    return buildRetObj(ret)
示例#13
0
def web_del_robot(db, env, arg):
    ret = robotService.delete_robot(db, arg)
    return buildRetObj(ret)
示例#14
0
def web_get_allrobot(db, env, arg):
    ret, data = robotService.get_allrobot(db, arg)
    return buildRetObj(ret, data)
示例#15
0
def web_get_robotlist(db, env, arg):
    (ret, data) = robotService.get_robotlist(db, arg)
    return buildRetObj(ret, data)
示例#16
0
def web_update_user(db, env, arg):
    ret = userService.update_user(db, arg)
    return buildRetObj(ret)
示例#17
0
def web_get_userlist(db, env, arg):
    (ret, data) = userService.get_userlist(db)
    return buildRetObj(ret, data)
示例#18
0
def web_remove_pricing(db, env, arg):
    ret, data = remove_pricing(db, arg["paras"])
    return buildRetObj(ret, data)
示例#19
0
def web_del_user(db, env, arg):
    ret = userService.delete_user(db, arg["paras"]["id"])
    return buildRetObj(ret)
示例#20
0
def web_delete_api(db, env, arg):
    ret = deleteApi(db, arg)
    return buildRetObj(ret, None)
示例#21
0
def web_del_user(db, env, arg):
    ret = userService.delete_user(db, arg)
    return buildRetObj(ret)
示例#22
0
def web_add_user(db, env, arg):
    ret = userService.add_user(db, arg)
    return buildRetObj(ret)
示例#23
0
def web_get_robot(db, env, arg):
    ret, data = robotService.get_robot(db, arg["paras"]["id"])
    return buildRetObj(ret, data)
示例#24
0
def web_get_product_types(db, env, arg):
    ret, data = get_product_types(db, arg["paras"])
    return buildRetObj(ret, data)
示例#25
0
def web_add_apiresult(db, env, arg, result=None):
    (ret, data) = addApiResult(db, env, arg, result)
    return buildRetObj(ret, data)
示例#26
0
文件: callapi.py 项目: maqg/wcrobot
    return 0, None


def get_server_key():
    return API_TEST_KEY


def api_call_server(address,
                    paras,
                    api_proto,
                    port=SERVER_PORT,
                    async=False,
                    https=False):
    (ret, errorLog) = parse_paras(paras, api_proto)
    if (ret):
        retObj = buildRetObj(ret, data=None, errorLog=errorLog)
        return ApiResponse(ret, retObj)
    (ret, resp) = api_call(address,
                           port,
                           api_proto["apikey"],
                           paras,
                           get_server_key(),
                           async,
                           server=True,
                           https=https)
    return ApiResponse(ret, resp)


def api_call_vr(address,
                paras,
                api_proto,
示例#27
0
def web_add_api(db, env, arg):
    paras = arg["paras"]
    (ret, data) = addApi(db, arg, paras)
    return buildRetObj(ret, data)
示例#28
0
def web_modify_password(db, env, arg):
    ret = userService.change_password(db, arg)
    return buildRetObj(ret)
示例#29
0
def web_get_apis(db, env, arg):
    ret, data = getApis(db, arg)
    return buildRetObj(ret, data)
示例#30
0
def web_reset_password(db, env, arg):
    ret = userService.reset_password(db, arg)
    return buildRetObj(ret)