Пример #1
0
    def driver_template(self, oMsg):
        if len(oMsg['BOS']) == 0:
            raise HandlerError(self.rsp_code['params_error'],
                               '%s does not exist' % self.driverId)

        return json.loads(oMsg['BOS'][0].get('Value'))
Пример #2
0
 def parse_device_info(self, oMsg):
     try:
         return oMsg['BOS'][0]
     except IndexError:
         raise HandlerError(self.rsp_code['params_error'],
                            '%s does not exist' % self.driverId)
Пример #3
0
    def get(self):
        try:
            self.get_init('deviceId', 'categroy')

            if self.categroy not in ('NSDevices', 'NSDevicesDriver', 'NSDevicesAlarmInfo', 'NSDevicesVarInfo', \
                    'NSDeviceFlowChart', 'NSDutyCard', 'NSDeviceUIFault', \
                    'NSDeviceUIRunState', 'NSDeviceUIParam', 'NSDeviceUIOverview'):
                raise HandlerError(
                    self.rsp_code['params_error'],
                    "categroy %s does not support" % self.categroy)

            tree_filter = '%s[]' % self.categroy
            if self.categroy == 'NSDevicesDriver':
                tree_filter = 'NSDevicesDriver[].NSDriverLogicDevice[].{NSDevicesCommunicateParameter[],NSDevicesCommunicateDataBlock[].NSDevicesCommunicateDataBlockParameter[]}'

            if self.categroy != 'NSDevices':
                tree_filter = 'NSDevices[].%s' % tree_filter

            msg = {
                "Type": "GetBOTreeReq",
                "DataModelName": "s_DeviceMan",
                "BOName": "NSDevices",
                "WhereType": "CONDITION",
                "Where": "DeviceID==\"%s\"" % self.deviceId,
                "TreeFilter": tree_filter,
            }
            device_data = yield self.genResult('dm', msg, self.parse_device)

            data = {}
            if self.categroy == 'NSDevices':
                data['NSDevices'] = [{
                    "ParameterName": k,
                    "ParameterValue": v
                } for k, v in device_data.items()]
            else:
                data['_ID'] = device_data.get('_ID')
                data[self.categroy] = device_data.get(self.categroy)
                if data.get(self.categroy) is None: data[self.categroy] = []
                elif self.categroy == 'NSDevicesVarInfo':
                    for b in data[self.categroy]:
                        b['RelatedVar'] = b.get('VarName')

            if self.categroy == 'NSDevicesDriver':
                if not data.get('NSDevicesDriver'):
                    data['NSDriverTemplate'] = {'Props': []}
                    self.send(self.SUCCESS, data)
                    return
                else:
                    msg = model_api.getDeviceDriverTemplates(
                        self.get_driver_type_list(data.get('NSDevicesDriver')))
                    data['NSDriverTemplate'] = yield self.genResult(
                        'dm', msg, self.parse_global_conf)
            else:
                props = yield self.genResult('dm',
                                             model_api.getDeviceTemplate(),
                                             self.device_template)

                msg = model_api.getMapOptions(props)
                if msg:
                    map_options = yield self.genResult('dm', msg,
                                                       self.parse_dict_man)
                    props = model_api.updateMapOptionsForProperties(
                        props, map_options)

                data['%sTemplate' % self.categroy] = {'Props': props}

            self.send(self.SUCCESS, data)

        except HandlerError as e:
            self._send(e.json_msg)
Пример #4
0
    def parse_device(self, oMsg):
        if not oMsg['BOTree'] or len(oMsg['BOTree']) == 0:
            raise HandlerError(self.rsp_code['system_error'],
                               '%s does not exist' % self.deviceId)

        return dict(oMsg['BOTree'][0])
Пример #5
0
 def member_infos(self, oMsg):
     if len(oMsg['BOS']) == 0:
         raise HandlerError(self.rsp_code['params_error'],
                            '%s does not exist' % ','.join(self.memberIds))
     self.memberInfos = oMsg['BOS']
Пример #6
0
 def member_info(self, oMsg):
     if len(oMsg['BOS']) == 0:
         raise HandlerError(self.rsp_code['params_error'],
                            '%s does not exist' % self.memberId)
     return oMsg['BOS'][0]
Пример #7
0
    def member_infos(self, oMsg):
        if len(oMsg['BOS']) < 1:
            raise HandlerError(self.rsp_code['params_error'],
                               '%s 用户不存在' % ','.join(self.memberIds))

        return oMsg['BOS']
Пример #8
0
    def member_unique(self, oMsg):
        if len(oMsg['BOS']) == 0: return

        usernames = [o['Name'] for o in oMsg['BOS']]
        raise HandlerError(self.rsp_code['params_error'],
                           '%s 用户已关联' % ','.join(usernames))
Пример #9
0
 def last_node(self, oMsg):
     if len(oMsg['Path']) == 1:
         raise HandlerError(
             self.rsp_code['params_error'],
             '无法移除%s用户唯一组织架构关系,请执行删除人员操作' % self.queryDeptUserId)