Exemplo n.º 1
0
    def update_info(self, device_sn, space_id, **kwargs):
        '''
        更改设备绑定的设备空间,以及设备位置等元信息;
        当更换设备的设备空间时,该接口是异步接口,可根据返回值的request_id请求获取异步任务状态接口获取请求状态
        :param device_sn:设备编号
        kwargs:
        space_id	string	是	目标设备空间id
        name	string	否	设备名称,长度限制80字节
        position	string	否	设备所在设备空间具体位置,长度限制80字节
        description	string	否	设备描述,长度限制512字节
        extra	string	否	设备额外信息,长度限制512字节
        '''
        method = 'PUT'
        path = self.api_version + '/devices/%s/update' % device_sn

        data = {'space_id': space_id}
        for k, v in kwargs.items():
            data.update({k: v}) if k in _device_info_feild else None

        headers = {'host': self.host, 'content-type': self.content_type}

        authorization = self.auth.get_sign(http_method=method,
                                           path=path,
                                           params=None,
                                           headers=headers)
        url = '{0}{1}'.format(self.base_url, path)
        print(url)

        ret, info = dohttp._put(url,
                                json.dumps(data),
                                authorization,
                                headers=headers)

        return ret, info
Exemplo n.º 2
0
    def user_faces_update(self, faceset_id, face_id, **kwargs):
        '''
        OpenAPI获取更新用户指令,内部对人脸库内用户信息(图片或附加信息)进行更新,
        返回本次操作的操作id,状态码与错误信息。
        :param faceset_id:
        :param face_id:
        :param kwargs:
        :return:
        '''
        method = 'PUT'
        path = self.api_version + '/facesets/{0}/faces/{1}'.format(
            faceset_id, face_id)

        data = {}
        for k, v in kwargs.items():
            if k in _user_face_list_feild:
                data.update({k: v})

        headers = {'host': self.host, 'conent-type': self.content_type}

        authorization = self.auth.get_sign(http_method=method,
                                           path=path,
                                           params=None,
                                           headers=headers)

        url = '{0}{1}'.format(self.base_url, path)
        print(url)

        ret, info = dohttp._put(url,
                                data=json.dumps(data),
                                auth=authorization,
                                headers=headers)

        return ret, info
Exemplo n.º 3
0
    def faceset_ipc_threshold_modify(self, faceset_id, device_sn, threshold):
        '''
        OpenAPI获取修改IPC人脸库阈值指令,内部更新IPC人脸库阈值,返回本次操作的操作id,状态码与错误信息
        :param faceset_id:
        :param device_sn:
        :param threshold:
        :return:
        '''
        method = 'PUT'
        path = self.api_version + '/facesets/%s/threshold' % (faceset_id)

        data = {'device_sn': device_sn, 'threshold': threshold}

        headers = {'host': self.host, 'content-type': self.content_type}

        authorization = self.auth.get_sign(http_method=method,
                                           path=path,
                                           params=None,
                                           headers=headers)
        url = '{0}{1}'.format(self.base_url, path)
        print(url)

        ret, info = dohttp._put(url,
                                data=json.dumps(data),
                                auth=authorization,
                                headers=headers)

        return ret, info
Exemplo n.º 4
0
    def pf_line_switch(self, device_sn, switch_status):
        '''
        用于查看客流的画的线的相关信息
        :param device_sn:
        :param switch_status: 开关状态,0为停止,1为启动
        :return:
        '''

        method = 'PUT'
        path = self.api_version + '/passengerflow/%s/switch' % device_sn

        data = {'switch_status': switch_status}

        headers = {'host': self.host, 'content-type': self.content_type}

        authorization = self.auth.get_sign(http_method=method,
                                           path=path,
                                           params=None,
                                           headers=headers)
        url = '{0}{1}'.format(self.base_url, path)
        print(url)

        ret, info = dohttp._put(url,
                                data=data,
                                auth=authorization,
                                headers=headers)

        return ret, info
Exemplo n.º 5
0
    def update(self, faceset_id, **kwargs):
        '''
        更新当前api调用者指定的人脸库相关的字段
        :param faceset_id:

        name	string	否	更改后的人脸库名,长度限制80字符
        extra	string	否	更改后的人脸库额外信息,长度限制512字符
        description	string	否	人脸库描述,长度限制512字符
        :return:
        '''
        method = 'PUT'
        path = self.api_version + '/facesets/%s' % faceset_id

        data = {}
        for k, v in kwargs.items():
            if k in _faseset_feild:
                data.update({k: v})

        headers = {'host': self.host, 'conent-type': self.content_type}

        authorization = self.auth.get_sign(http_method=method,
                                           path=path,
                                           params=None,
                                           headers=headers)

        url = '{0}{1}'.format(self.base_url, path)
        print(url)

        ret, info = dohttp._put(url,
                                data=json.dumps(data),
                                auth=authorization,
                                headers=headers)

        return ret, info
Exemplo n.º 6
0
    def update_user(self, faceset_id, face_id, **kwargs):
        '''
        用于对人脸库中指定的用户,更新其信息,目前仅支持人脸特征照片、性别和年龄段
        :param faceset_id:
        :param face_id:
        :return:
        '''
        method = 'PUT'
        path = self.api_version + '/facesets/{0}/faces/{1}'.format(
            faceset_id, face_id)

        data = {}
        for k, v in kwargs.items():
            if k in _face_user_register_feild:
                data.update({k: v})

        headers = {'host': self.host, 'conent-type': self.content_type}

        authorization = self.auth.get_sign(http_method=method,
                                           path=path,
                                           params=None,
                                           headers=headers)

        url = '{0}{1}'.format(self.base_url, path)
        print(url)

        ret, info = dohttp._put(url,
                                data=json.dumps(data),
                                auth=authorization,
                                headers=headers)

        return ret, info
Exemplo n.º 7
0
    def update(self, space_id, **kwargs):
        '''
        更新当前api调用者指定的设备空间相关的字段
        :param space_id:
        :param name	string	否	设备空间名字,不超80个字符
        :param description	string	否	设备空间描述
        :param extra	string	否	设备空间其他冗余信息
        :return:
        '''
        method = 'PUT'
        path = self.api_version + '/device_spaces/%s' % space_id

        data = {}
        for k, v in kwargs.items():
            if k in _space_config_feild:
                data.update({k: v})

        headers = {'host': self.host, 'content-type': self.content_type}

        authorization = self.auth.get_sign(http_method=method,
                                           path=path,
                                           params=None,
                                           headers=headers)

        # url = 'http://{0}{1}?authorization={2}'.format(self.host, path, authorization)
        url = '{0}{1}'.format(self.base_url, path)
        print(url)

        ret, info = dohttp._put(url,
                                json.dumps(data),
                                authorization,
                                '',
                                headers=headers)

        return ret, info
Exemplo n.º 8
0
    def update_config(self, device_sn, device_cfg):
        '''
        更改设备绑定的设备空间,以及设备位置等元信息;
        当更换设备的设备空间时,该接口是异步接口,可根据返回值的request_id请求获取异步任务状态接口获取请求状态
        :param device_sn:设备编号

        kwargs:
        module	Array	是	设备配置模块,详见module说明(设备配置参数下发)

        module 说明:
        name	string	是	模块名称,可配置的名称详见module可配置名称说明(设备配置参数下发)
        parm	Array	是	模块参数配置数组,详见parm说明(设备配置参数下发)

        "module":[{
            "name":"capture_config",
            "parm":[
                {
                    "name":"aaa",
                    "value":"aaa"
                },
                {
                    "name":"bbb",
                    "value":"bbb"
                }
            ]
        }]
        '''

        method = 'PUT'
        path = self.api_version + '/devices/%s' % device_sn

        moduls = 'capture_config'
        if isinstance(device_cfg, list):
            params = [device_cfg]
        else:
            raise ValueError('device_cfg must be a list')

        data = {'moduls': [{'name': moduls, 'parm': params}]}

        headers = {'host': self.host, 'content-type': self.content_type}

        authorization = self.auth.get_sign(http_method=method,
                                           path=path,
                                           params=None,
                                           headers=headers)
        url = '{0}{1}'.format(self.base_url, path)
        print(url)
        ret, info = dohttp._put(url,
                                json.dumps(data),
                                authorization,
                                headers=headers)
        return ret, info
    def visitors_sub(self, topic_name, topic_id, client_id):
        '''
        指定设备空间或设备订阅,订阅后可以通过建立websocket长连接监听到店记录的推送

        :param topic_name:  string	是	订阅的topic_name,当前支持两种订阅name,space和device
        :param topic_id:    string	是	订阅的topic_id, 当订阅name是space时,表示space_id,订阅name是device时,表示device_sn
        :param client_id:   string	是	用户自定义,用户在websocket是需要传入的标识符,长度不超过24个字符,只支持大小写和数字
        :return:
        '''
        method = 'PUT'
        path = self.api_version + '/analysis_tools/visitors/sub'

        if not topic_name in _topic_name_feild:
            raise ValueError('topic_name [%s] error!!' % topic_name)

        data = {
            'topic_name': topic_name,
            'topic_id': topic_id,
            'client_id': client_id
        }

        headers = {'host': self.host, 'conent-type': self.content_type}

        authorization = self.auth.get_sign(http_method=method,
                                           path=path,
                                           params=None,
                                           headers=headers)

        url = '{0}{1}'.format(self.base_url, path)
        print(url)

        ret, info = dohttp._put(url,
                                data=json.dumps(data),
                                auth=authorization,
                                headers=headers)

        return ret, info