def doRenewDBInstances(args, parsed_globals):
    g_param = parse_global_arg(parsed_globals)

    cred = credential.Credential(g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint]
    )
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.MongodbClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.RenewDBInstancesRequest()
    model.from_json_string(json.dumps(args))
    rsp = client.RenewDBInstances(model)
    result = rsp.to_json_string()
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8'))  # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
예제 #2
0
def doStartEncryption(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("StartEncryption", g_param[OptionsDefine.Version])
        return

    param = {
        "CosEndPoint": argv.get("--CosEndPoint"),
        "CosSecretId": argv.get("--CosSecretId"),
        "CosSecretKey": argv.get("--CosSecretKey"),
        "DrmType": argv.get("--DrmType"),
        "SourceObject": Utils.try_to_json(argv, "--SourceObject"),
        "OutputObjects": Utils.try_to_json(argv, "--OutputObjects"),
    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId],
                                 g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(
            g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint])
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.DrmClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.StartEncryptionRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.StartEncryption(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8'))  # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output],
                        g_param[OptionsDefine.Filter])
예제 #3
0
def doGetMonitorData(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("GetMonitorData", g_param[OptionsDefine.Version])
        return

    param = {
        "Namespace": argv.get("--Namespace"),
        "MetricName": argv.get("--MetricName"),
        "Instances": Utils.try_to_json(argv, "--Instances"),
        "Period": Utils.try_to_json(argv, "--Period"),
        "StartTime": argv.get("--StartTime"),
        "EndTime": argv.get("--EndTime"),
    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId],
                                 g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(
            g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint])
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.MonitorClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.GetMonitorDataRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.GetMonitorData(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8'))  # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output],
                        g_param[OptionsDefine.Filter])
예제 #4
0
def doDescribeCreditResult(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("DescribeCreditResult", g_param[OptionsDefine.Version])
        return

    param = {
        "Module": Utils.try_to_json(argv, "--Module"),
        "Operation": Utils.try_to_json(argv, "--Operation"),
        "InstId": Utils.try_to_json(argv, "--InstId"),
        "ProductId": Utils.try_to_json(argv, "--ProductId"),
        "CaseId": Utils.try_to_json(argv, "--CaseId"),
        "RequestDate": Utils.try_to_json(argv, "--RequestDate"),
    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId],
                                 g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(
            g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint])
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.CrClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.DescribeCreditResultRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.DescribeCreditResult(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8'))  # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output],
                        g_param[OptionsDefine.Filter])
예제 #5
0
def doDescribeBillResourceSummary(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("DescribeBillResourceSummary",
                  g_param[OptionsDefine.Version])
        return

    param = {
        "Offset": Utils.try_to_json(argv, "--Offset"),
        "Limit": Utils.try_to_json(argv, "--Limit"),
        "PeriodType": argv.get("--PeriodType"),
        "Month": argv.get("--Month"),
        "NeedRecordNum": Utils.try_to_json(argv, "--NeedRecordNum"),
    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId],
                                 g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(
            g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint])
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.BillingClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.DescribeBillResourceSummaryRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.DescribeBillResourceSummary(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8'))  # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output],
                        g_param[OptionsDefine.Filter])
예제 #6
0
def doLookUpEvents(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("LookUpEvents", g_param[OptionsDefine.Version])
        return

    param = {
        "EndTime": Utils.try_to_json(argv, "--EndTime"),
        "StartTime": Utils.try_to_json(argv, "--StartTime"),
        "LookupAttributes": Utils.try_to_json(argv, "--LookupAttributes"),
        "MaxResults": Utils.try_to_json(argv, "--MaxResults"),
        "Mode": argv.get("--Mode"),
        "NextToken": argv.get("--NextToken"),
    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId],
                                 g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(
            g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint])
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.CloudauditClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.LookUpEventsRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.LookUpEvents(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8'))  # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output],
                        g_param[OptionsDefine.Filter])
예제 #7
0
def doSearchFaces(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("SearchFaces", g_param[OptionsDefine.Version])
        return

    param = {
        "GroupIds": Utils.try_to_json(argv, "--GroupIds"),
        "Image": Utils.try_to_json(argv, "--Image"),
        "Url": Utils.try_to_json(argv, "--Url"),
        "MaxFaceNum": Utils.try_to_json(argv, "--MaxFaceNum"),
        "MinFaceSize": Utils.try_to_json(argv, "--MinFaceSize"),
        "MaxPersonNum": Utils.try_to_json(argv, "--MaxPersonNum"),
    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId],
                                 g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(
            g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint])
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.IaiClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.SearchFacesRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.SearchFaces(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8'))  # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output],
                        g_param[OptionsDefine.Filter])
예제 #8
0
def transmit_oral_process(sessionId,
                          userVoiceData):  #  语音段唯一标识,一个完整语音一个SessionId。
    try:
        # 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey
        cred = credential.Credential(secretId, secretKey)

        # 实例化一个http选项,可选的,没有特殊需求可以跳过。
        httpProfile = HttpProfile()
        httpProfile.reqMethod = "POST"  # post请求(默认为post请求)
        httpProfile.reqTimeout = 30  # 请求超时时间,单位为秒(默认60秒)
        httpProfile.endpoint = "soe.tencentcloudapi.com"  # 指定接入地域域名(默认就近接入)

        clientProfile = ClientProfile()
        clientProfile.signMethod = "TC3-HMAC-SHA256"  # 指定签名算法(默认为HmacSHA256)
        clientProfile.unsignedPayload = True
        clientProfile.httpProfile = httpProfile

        client = soe_client.SoeClient(cred, "", clientProfile)
        req = models.TransmitOralProcessRequest()
        req.SessionId = sessionId
        req.VoiceFileType = 2  # 语音文件类型 1:raw, 2:wav, 3:mp3(三种格式目前仅支持16k采样率16bit编码单声道
        req.SeqId = 1  # 流式数据包的序号,从1开始,当IsEnd字段为1后后续序号无意义,当
        #IsLongLifeSession不为1且为非流式模式时无意义。
        req.VoiceEncodeType = 1  # 语音编码类型 1:pcm。
        req.IsEnd = 1  #  是否传输完毕标志,若为0表示未完毕,若为1则传输完毕开始评估,非流式模式下无意义

        req.UserVoiceData = userVoiceData  # 当前数据包数据, 流式模式下数据包大小可以按需设置,数据包大小必须 >= 4K,且必
        #须保证分片帧完整(16bit的数据必须保证音频长度为偶数),编码格式要求为BASE64。

        # process
        resp = client.TransmitOralProcess(req)

        # 输出json格式的字符串回包
        print("%s" % resp.to_json_string())

    except TencentCloudSDKException as err:
        print("%s" % err)
예제 #9
0
파일: asr.py 프로젝트: SCys/GoalKeepr
async def tx_asr(audio_data: str) -> str:
    """腾讯云 ASR"""
    config = manager.config
    id = config["asr"]["tx_id"]
    key = config["asr"]["tx_key"]

    try:
        cred = credential.Credential(id, key)
        httpProfile = HttpProfile()
        httpProfile.endpoint = "asr.tencentcloudapi.com"

        clientProfile = ClientProfile()
        clientProfile.httpProfile = httpProfile
        client = asr_client.AsrClient(cred, "", clientProfile)

        req = models.CreateRecTaskRequest()
        req.from_json_string(
            dumps(
                {
                    "EngineModelType": "16k_zh",
                    "ChannelNum": 1,
                    "SpeakerDiarization": 0,
                    "SpeakerNumber": 1,
                    "ResTextFormat": 2,
                    "SourceType": 1,
                    "Data": audio_data,
                }
            )
        )

        resp = client.CreateRecTask(req)
        data = resp._serialize(allow_none=True)

        logger.info(f"tencent cloud sdk asr is done: {data['Data']}")
        return data["Data"]["TaskId"]
    except TencentCloudSDKException:
        logger.exception("tencent cloud sdk error")
예제 #10
0
def doUpdateCfsRule(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("UpdateCfsRule", g_param[OptionsDefine.Version])
        return

    param = {
        "PGroupId": argv.get("--PGroupId"),
        "RuleId": argv.get("--RuleId"),
        "AuthClientIp": argv.get("--AuthClientIp"),
        "RWPermission": argv.get("--RWPermission"),
        "UserPermission": argv.get("--UserPermission"),
        "Priority": Utils.try_to_json(argv, "--Priority"),
    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId],
                                 g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(
            g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint])
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.CfsClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.UpdateCfsRuleRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.UpdateCfsRule(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8'))  # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output],
                        g_param[OptionsDefine.Filter])
예제 #11
0
def doDescribeGameServerSessions(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("DescribeGameServerSessions", g_param[OptionsDefine.Version])
        return

    param = {
        "AliasId": argv.get("--AliasId"),
        "FleetId": argv.get("--FleetId"),
        "GameServerSessionId": argv.get("--GameServerSessionId"),
        "Limit": Utils.try_to_json(argv, "--Limit"),
        "NextToken": argv.get("--NextToken"),
        "StatusFilter": argv.get("--StatusFilter"),
    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId],
                                 g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(
            g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint])
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.GseClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.DescribeGameServerSessionsRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.DescribeGameServerSessions(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8'))  # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output],
                        g_param[OptionsDefine.Filter])
예제 #12
0
def doUpgradeLicense(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("UpgradeLicense", g_param[OptionsDefine.Version])
        return

    param = {
        "InstanceId": argv.get("--InstanceId"),
        "LicenseType": argv.get("--LicenseType"),
        "AutoVoucher": Utils.try_to_json(argv, "--AutoVoucher"),
        "VoucherIds": Utils.try_to_json(argv, "--VoucherIds"),
        "BasicSecurityType": Utils.try_to_json(argv, "--BasicSecurityType"),
        "ForceRestart": Utils.try_to_json(argv, "--ForceRestart"),
    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId],
                                 g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(
            g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint])
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.EsClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.UpgradeLicenseRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.UpgradeLicense(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8'))  # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output],
                        g_param[OptionsDefine.Filter])
예제 #13
0
def doModifySiteAttribute(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("ModifySiteAttribute", g_param[OptionsDefine.Version])
        return

    param = {
        "SiteId": Utils.try_to_json(argv, "--SiteId"),
        "Name": argv.get("--Name"),
        "NeedLogin": Utils.try_to_json(argv, "--NeedLogin"),
        "LoginCookie": argv.get("--LoginCookie"),
        "LoginCheckUrl": argv.get("--LoginCheckUrl"),
        "LoginCheckKw": argv.get("--LoginCheckKw"),
        "ScanDisallow": argv.get("--ScanDisallow"),

    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint]
    )
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.CwsClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.ModifySiteAttributeRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.ModifySiteAttribute(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8')) # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
예제 #14
0
def doGetDetectInfoEnhanced(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("GetDetectInfoEnhanced", g_param[OptionsDefine.Version])
        return

    param = {
        "BizToken": argv.get("--BizToken"),
        "RuleId": argv.get("--RuleId"),
        "InfoType": argv.get("--InfoType"),
        "BestFramesCount": Utils.try_to_json(argv, "--BestFramesCount"),
        "IsCutIdCardImage": Utils.try_to_json(argv, "--IsCutIdCardImage"),
        "IsNeedIdCardAvatar": Utils.try_to_json(argv, "--IsNeedIdCardAvatar"),
    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId],
                                 g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(
            g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint])
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.FaceidClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.GetDetectInfoEnhancedRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.GetDetectInfoEnhanced(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8'))  # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output],
                        g_param[OptionsDefine.Filter])
예제 #15
0
def doLivenessRecognition(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("LivenessRecognition", g_param[OptionsDefine.Version])
        return

    param = {
        "IdCard": argv.get("--IdCard"),
        "Name": argv.get("--Name"),
        "VideoBase64": argv.get("--VideoBase64"),
        "LivenessType": argv.get("--LivenessType"),
        "ValidateData": argv.get("--ValidateData"),
        "Optional": argv.get("--Optional"),
    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId],
                                 g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(
            g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint])
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.FaceidClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.LivenessRecognitionRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.LivenessRecognition(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8'))  # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output],
                        g_param[OptionsDefine.Filter])
예제 #16
0
def doFaceFusion(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("FaceFusion", g_param[OptionsDefine.Version])
        return

    param = {
        "ProjectId": Utils.try_to_json(argv, "--ProjectId"),
        "ModelId": Utils.try_to_json(argv, "--ModelId"),
        "Image": Utils.try_to_json(argv, "--Image"),
        "RspImgType": Utils.try_to_json(argv, "--RspImgType"),
        "PornDetect": Utils.try_to_json(argv, "--PornDetect"),
        "CelebrityIdentify": Utils.try_to_json(argv, "--CelebrityIdentify"),
    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId],
                                 g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(
            g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint])
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.FacefusionClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.FaceFusionRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.FaceFusion(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8'))  # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output],
                        g_param[OptionsDefine.Filter])
예제 #17
0
 def send_message_by_sms(cls, message):
     cred = credential.Credential(SMSConfig.secretId, SMSConfig.secretKey)
     # 实例化一个http选项,可选的,没有特殊需求可以跳过。
     httpProfile = HttpProfile()
     # 如果需要指定proxy访问接口,可以按照如下方式初始化hp
     httpProfile.reqMethod = "POST"  # post请求(默认为post请求)
     httpProfile.reqTimeout = 30  # 请求超时时间,单位为秒(默认60秒)
     httpProfile.endpoint = "sms.tencentcloudapi.com"  # 指定接入地域域名(默认就近接入)
     # 实例化一个客户端配置对象,可以指定超时时间等配置
     clientProfile = ClientProfile()
     clientProfile.signMethod = "TC3-HMAC-SHA256"  # 指定签名算法
     clientProfile.language = "en-US"
     clientProfile.httpProfile = httpProfile
     # 第二个参数是地域信息,可以直接填写字符串ap-guangzhou,或者引用预设的常量
     client = sms_client.SmsClient(cred, "ap-guangzhou", clientProfile)
     req = models.SendSmsRequest()
     # 基本类型的设置:
     req.SmsSdkAppId = SMSConfig.SdkAppId
     # 短信签名内容: 使用 UTF-8 编码,必须填写已审核通过的签名,签名信息可登录 [短信控制台] 查看
     req.SignName = SMSConfig.signName
     # 短信码号扩展号: 默认未开通,如需开通请联系 [sms helper]
     req.ExtendCode = ""
     # 用户的 session 内容: 可以携带用户侧 ID 等上下文信息,server 会原样返回
     req.SessionContext = "xxx"
     # 国际/港澳台短信 senderid: 国内短信填空,默认未开通,如需开通请联系 [sms helper]
     req.SenderId = ""
     # 下发手机号码,采用 E.164 标准,+[国家或地区码][手机号]
     # 示例如:+8613711112222, 其中前面有一个+号 ,86为国家码,13711112222为手机号,最多不要超过200个手机号
     req.PhoneNumberSet = SMSConfig.sendPhone
     # 模板 ID: 必须填写已审核通过的模板 ID。模板ID可登录 [短信控制台] 查看
     req.TemplateId = SMSConfig.templateId
     # 模板参数: 若无模板参数,则设置为空
     req.TemplateParamSet = [i for i in message[0].split(',') if i]
     # 通过client对象调用DescribeInstances方法发起请求。注意请求方法名与请求对象是对应的。
     # 返回的resp是一个DescribeInstancesResponse类的实例,与请求对象对应。
     resp = client.SendSms(req)
     print(resp)
예제 #18
0
def doMarketingValueJudgement(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("MarketingValueJudgement", g_param[OptionsDefine.Version])
        return

    param = {
        "AccountType": Utils.try_to_json(argv, "--AccountType"),
        "Uid": argv.get("--Uid"),
        "UserIp": argv.get("--UserIp"),
        "PostTime": Utils.try_to_json(argv, "--PostTime"),
        "Imei": argv.get("--Imei"),
        "Referer": argv.get("--Referer"),
    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId],
                                 g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(
            g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint])
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.MvjClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.MarketingValueJudgementRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.MarketingValueJudgement(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8'))  # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output],
                        g_param[OptionsDefine.Filter])
예제 #19
0
def doUpdateFunctionCode(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("UpdateFunctionCode", g_param[OptionsDefine.Version])
        return

    param = {
        "Handler": Utils.try_to_json(argv, "--Handler"),
        "FunctionName": Utils.try_to_json(argv, "--FunctionName"),
        "CosBucketName": Utils.try_to_json(argv, "--CosBucketName"),
        "CosObjectName": Utils.try_to_json(argv, "--CosObjectName"),
        "ZipFile": Utils.try_to_json(argv, "--ZipFile"),
        "CosBucketRegion": Utils.try_to_json(argv, "--CosBucketRegion"),
    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId],
                                 g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(
            g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint])
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.ScfClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.UpdateFunctionCodeRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.UpdateFunctionCode(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8'))  # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output],
                        g_param[OptionsDefine.Filter])
예제 #20
0
def doInquiryPriceDbauditInstance(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("InquiryPriceDbauditInstance",
                  g_param[OptionsDefine.Version])
        return

    param = {
        "InstanceVersion": argv.get("--InstanceVersion"),
        "InquiryType": argv.get("--InquiryType"),
        "TimeSpan": Utils.try_to_json(argv, "--TimeSpan"),
        "TimeUnit": argv.get("--TimeUnit"),
        "ServiceRegion": argv.get("--ServiceRegion"),
    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId],
                                 g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(
            g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint])
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.CdsClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.InquiryPriceDbauditInstanceRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.InquiryPriceDbauditInstance(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8'))  # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output],
                        g_param[OptionsDefine.Filter])
예제 #21
0
def doModifyDiskAttributes(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("ModifyDiskAttributes", g_param[OptionsDefine.Version])
        return

    param = {
        "DiskIds": Utils.try_to_json(argv, "--DiskIds"),
        "ProjectId": Utils.try_to_json(argv, "--ProjectId"),
        "DiskName": Utils.try_to_json(argv, "--DiskName"),
        "Portable": Utils.try_to_json(argv, "--Portable"),
        "DeleteWithInstance": Utils.try_to_json(argv, "--DeleteWithInstance"),
        "DiskType": Utils.try_to_json(argv, "--DiskType"),
    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId],
                                 g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(
            g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint])
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.CbsClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.ModifyDiskAttributesRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.ModifyDiskAttributes(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8'))  # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output],
                        g_param[OptionsDefine.Filter])
예제 #22
0
def doControlDeviceData(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("ControlDeviceData", g_param[OptionsDefine.Version])
        return

    param = {
        "ProductId": argv.get("--ProductId"),
        "DeviceName": argv.get("--DeviceName"),
        "Data": argv.get("--Data"),
        "Method": argv.get("--Method"),
        "DeviceId": argv.get("--DeviceId"),
    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId],
                                 g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(
            g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint])
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.IotexplorerClient(cred, g_param[OptionsDefine.Region],
                                   profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.ControlDeviceDataRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.ControlDeviceData(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8'))  # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output],
                        g_param[OptionsDefine.Filter])
예제 #23
0
def doBeautifyPic(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("BeautifyPic", g_param[OptionsDefine.Version])
        return

    param = {
        "Image": argv.get("--Image"),
        "Url": argv.get("--Url"),
        "Whitening": Utils.try_to_json(argv, "--Whitening"),
        "Smoothing": Utils.try_to_json(argv, "--Smoothing"),
        "FaceLifting": Utils.try_to_json(argv, "--FaceLifting"),
        "EyeEnlarging": Utils.try_to_json(argv, "--EyeEnlarging"),
    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId],
                                 g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(
            g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint])
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.FmuClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.BeautifyPicRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.BeautifyPic(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8'))  # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output],
                        g_param[OptionsDefine.Filter])
예제 #24
0
def doInvoke(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("Invoke", g_param[OptionsDefine.Version])
        return

    param = {
        "FunctionName": argv.get("--FunctionName"),
        "InvocationType": argv.get("--InvocationType"),
        "Qualifier": argv.get("--Qualifier"),
        "ClientContext": argv.get("--ClientContext"),
        "LogType": argv.get("--LogType"),
        "Namespace": argv.get("--Namespace"),
    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId],
                                 g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(
            g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint])
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.ScfClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.InvokeRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.Invoke(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8'))  # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output],
                        g_param[OptionsDefine.Filter])
예제 #25
0
def doCreateRsgAsGroup(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("CreateRsgAsGroup", g_param[OptionsDefine.Version])
        return

    param = {
        "RsgId": argv.get("--RsgId"),
        "MaxSize": Utils.try_to_json(argv, "--MaxSize"),
        "MinSize": Utils.try_to_json(argv, "--MinSize"),
        "InstanceType": argv.get("--InstanceType"),
        "Cluster": argv.get("--Cluster"),
        "Name": argv.get("--Name"),
        "DesiredSize": Utils.try_to_json(argv, "--DesiredSize"),

    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint]
    )
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.TiemsClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.CreateRsgAsGroupRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.CreateRsgAsGroup(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8')) # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
예제 #26
0
    def main_ocr(self):
        print('loading Tencent ocr')
        img = self._preprocess()
        formatted_output = {}
        try:

            cred = credential.Credential("AKID0nLdgTSHadQxFJgi1JL7evxjFVhdxjtn", "oMgz2pMdfRwCPM3UgdKlx71f4D7k8GME")
            http_profile = HttpProfile()
            http_profile.endpoint = "ocr.tencentcloudapi.com"

            client_profile = ClientProfile()
            client_profile.httpProfile = http_profile
            client = ocr_client.OcrClient(cred, "ap-guangzhou", client_profile)

            req = models.GeneralAccurateOCRRequest()
            # req.ImageUrl = "https://mc.qcloudimg.com/static/img/6d4f1676deba26377d4303a462ca5074/image.png"
            req.ImageBase64 = img
            resp = client.GeneralAccurateOCR(req)
            resp_json = resp.to_json_string()
            resp_dict = json.loads(resp_json)
            print(resp_dict)
            for ocr_dict in resp_dict['TextDetections']:
                ocr_text = ocr_dict['DetectedText']
                print(ocr_text)
                ocr_polygon = ocr_dict['Polygon']  # four conner points
                point1, point2, point3, point4 = ocr_polygon[:]
                formatted_output[(point2['X'] + self.min_point[0],
                                  point2['Y'] + self.min_point[1],
                                 point4['X'] - point2['X'],
                                 point4['Y'] - point2['Y'])] = ocr_text
            # print(resp_json)
            # print(resp_dict['TextDetections'])
            # print(formatted_output)
            return formatted_output

        except TencentCloudSDKException as err:
            print(err)
예제 #27
0
def doGetBlockListHandler(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("GetBlockListHandler", g_param[OptionsDefine.Version])
        return

    param = {
        "Module": argv.get("--Module"),
        "Operation": argv.get("--Operation"),
        "Offset": Utils.try_to_json(argv, "--Offset"),
        "Limit": Utils.try_to_json(argv, "--Limit"),
        "GroupPk": argv.get("--GroupPk"),
        "BlockHash": argv.get("--BlockHash"),
    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId],
                                 g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(
            g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint])
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.TbaasClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.GetBlockListHandlerRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.GetBlockListHandler(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8'))  # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output],
                        g_param[OptionsDefine.Filter])
예제 #28
0
def doDeregisterTargets(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("DeregisterTargets", g_param[OptionsDefine.Version])
        return

    param = {
        "LoadBalancerId": Utils.try_to_json(argv, "--LoadBalancerId"),
        "ListenerId": Utils.try_to_json(argv, "--ListenerId"),
        "Targets": Utils.try_to_json(argv, "--Targets"),
        "LocationId": Utils.try_to_json(argv, "--LocationId"),
        "Domain": Utils.try_to_json(argv, "--Domain"),
        "Url": Utils.try_to_json(argv, "--Url"),
    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId],
                                 g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(
            g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint])
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.ClbClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.DeregisterTargetsRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.DeregisterTargets(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8'))  # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output],
                        g_param[OptionsDefine.Filter])
예제 #29
0
def doDescribeUserCmdTaskInfo(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("DescribeUserCmdTaskInfo", g_param[OptionsDefine.Version])
        return

    param = {
        "TaskId": Utils.try_to_json(argv, "--TaskId"),
        "Offset": Utils.try_to_json(argv, "--Offset"),
        "Limit": Utils.try_to_json(argv, "--Limit"),
        "OrderField": Utils.try_to_json(argv, "--OrderField"),
        "Order": Utils.try_to_json(argv, "--Order"),
        "SearchKey": Utils.try_to_json(argv, "--SearchKey"),
    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId],
                                 g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(
            g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint])
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.BmClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.DescribeUserCmdTaskInfoRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.DescribeUserCmdTaskInfo(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8'))  # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output],
                        g_param[OptionsDefine.Filter])
예제 #30
0
def doCreateServiceConfig(argv, arglist):
    g_param = parse_global_arg(argv)
    if "help" in argv:
        show_help("CreateServiceConfig", g_param[OptionsDefine.Version])
        return

    param = {
        "Name": argv.get("--Name"),
        "Runtime": argv.get("--Runtime"),
        "ModelUri": argv.get("--ModelUri"),
        "Cpu": Utils.try_to_json(argv, "--Cpu"),
        "Memory": Utils.try_to_json(argv, "--Memory"),
        "TflopUnits": Utils.try_to_json(argv, "--TflopUnits"),
        "GpuMemory": Utils.try_to_json(argv, "--GpuMemory"),

    }
    cred = credential.Credential(g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey])
    http_profile = HttpProfile(
        reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
        reqMethod="POST",
        endpoint=g_param[OptionsDefine.Endpoint]
    )
    profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
    mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
    client = mod.TiemsClient(cred, g_param[OptionsDefine.Region], profile)
    client._sdkVersion += ("_CLI_" + __version__)
    models = MODELS_MAP[g_param[OptionsDefine.Version]]
    model = models.CreateServiceConfigRequest()
    model.from_json_string(json.dumps(param))
    rsp = client.CreateServiceConfig(model)
    result = rsp.to_json_string()
    jsonobj = None
    try:
        jsonobj = json.loads(result)
    except TypeError as e:
        jsonobj = json.loads(result.decode('utf-8')) # python3.3
    FormatOutput.output("action", jsonobj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])