コード例 #1
0
ファイル: snap.py プロジェクト: marcomafcorp/synapse
    def _getNodeFnib(self, name, valu):
        '''
        return a form, norm, info, buid tuple
        '''
        form = self.model.form(name)
        if form is None:
            raise s_exc.NoSuchForm(name=name)

        try:
            norm, info = form.type.norm(valu)
        except s_exc.BadTypeValu as e:
            raise s_exc.BadPropValu(prop=form.name,
                                    valu=valu,
                                    mesg=e.get('mesg'),
                                    name=e.get('name')) from None
        except Exception as e:
            raise s_exc.BadPropValu(prop=form.name, valu=valu, mesg=str(e))

        buid = s_common.buid((form.name, norm))
        return form, norm, info, buid
コード例 #2
0
 async def _testRuntPropSetLulz(self, node, prop, valu):
     curv = node.get(prop.name)
     valu, _ = prop.type.norm(valu)
     if curv == valu:
         return False
     if not valu.endswith('.sys'):
         raise s_exc.BadPropValu(mesg='test:runt:lulz must end with ".sys"',
                                 valu=valu,
                                 name=prop.full)
     node.props[prop.name] = valu
     # In this test helper, we do NOT persist the change to our in-memory
     # storage of row data, so a re-lift of the node would not reflect the
     # change that a user made here.
     return True
コード例 #3
0
ファイル: syntax.py プロジェクト: rjammala/synapse
async def getRemoteParseInfo(proxy):
    '''
    Returns a parseinfo dict from a cortex proxy
    '''
    coreinfo = await proxy.getCoreInfo()
    if 'stormcmds' not in coreinfo or 'modeldef' not in coreinfo:
        raise s_exc.BadPropValu()
    modelinfo = s_datamodel.ModelInfo()
    modelinfo.addDataModels(coreinfo['modeldef'])
    parseinfo = {
        'stormcmds': coreinfo['stormcmds'],
        'modelinfo': modelinfo
    }
    return parseinfo