Exemple #1
0
    def register_pe(self, fullname, className, path):
        '''
        Registers a dispel4py processing element (PE) with the VERCE Registry. The PE is registered under 
        'fullname' and it is identified by 'className'. 'path' is the path to a file containing
        the source code of the PE to be registered.
        '''
        pkg, simpleName = split_name(fullname)

        # load the code
        peImpl = utils.loadSource(simpleName, path, className)()

        # prepare the PE signature
        peSig = {}
        peSig["user"] = {'username': self.user}
        peSig["workspaceId"] = self.workspace
        peSig["pckg"] = pkg
        peSig["name"] = simpleName
        connections = []
        for conx in peImpl.inputconnections.values():
            connection = {}
            connection["name"] = conx['name']
            connection["kind"] = 0
            connection["modifiers"] = []
            connections.append(connection)
        for conx in peImpl.outputconnections.values():
            connection = {}
            connection["name"] = conx['name']
            connection["kind"] = 1
            connection["modifiers"] = []
            connections.append(connection)
        peSig["connections"] = connections
        data = {}
        data["pesig"] = peSig

        # Register generic signature
        print "Registering PE " + simpleName + " in " + pkg
        genDefId = self.register_gendef(pkg, simpleName)
        print "Registered generic definition: id = %s" % genDefId
        try:
            # Register PE signature
            peSig["genericDefId"] = genDefId
            response = requests.post(self.registry_url + "pe/",
                                     data=json.dumps(data),
                                     headers=getHeaders(self.token))
            try:
                response.raise_for_status()
            except:
                requests.delete(self.registry_url + "gendef/%s" % genDefId)
                raise RegistrationFailed, "Registration of PE signature failed", sys.exc_info(
                )[2]
            peId = response.json()["id"]
            print "Registered PE signature:   id = %s" % peId
            # Register implementation
            implId = self.register_implementation(peId, pkg, simpleName, path)
            print "Registered implementation:     id = %s" % implId
        except:
            # delete everything that was registered if anything went wrong
            requests.delete(self.registry_url + "gendef/%s" % genDefId)
            raise
Exemple #2
0
 def register_pe(self, fullname, className, path):   
     '''
     Registers a dispel4py processing element (PE) with the VERCE Registry. The PE is registered under 
     'fullname' and it is identified by 'className'. 'path' is the path to a file containing
     the source code of the PE to be registered.
     '''          
     pkg, simpleName = split_name(fullname)
     
     # load the code
     peImpl = utils.loadSource(simpleName, path, className)()
     
     # prepare the PE signature
     peSig = {}
     peSig["user"] = { 'username' : self.user }
     peSig["workspaceId"] = self.workspace
     peSig["pckg"] = pkg
     peSig["name"] = simpleName
     connections = []
     for conx in peImpl.inputconnections.values():
         connection = {}
         connection["name"] = conx['name']
         connection["kind"] = 0
         connection["modifiers"] = []
         connections.append(connection)
     for conx in peImpl.outputconnections.values():
         connection = {}
         connection["name"] = conx['name']
         connection["kind"] = 1
         connection["modifiers"] = []
         connections.append(connection)
     peSig["connections"] = connections
     data = {}
     data["pesig"] = peSig
     
     # Register generic signature
     print "Registering PE " + simpleName + " in " + pkg
     genDefId = self.register_gendef(pkg, simpleName)
     print "Registered generic definition: id = %s" % genDefId
     try:
         # Register PE signature
         peSig["genericDefId"] = genDefId
         response = requests.post(self.registry_url + "pe/", data=json.dumps(data), headers=getHeaders(self.token))
         try:
             response.raise_for_status()
         except:
             requests.delete(self.registry_url + "gendef/%s" % genDefId)
             raise RegistrationFailed, "Registration of PE signature failed", sys.exc_info()[2]
         peId = response.json()["id"]
         print "Registered PE signature:   id = %s" % peId
         # Register implementation
         implId = self.register_implementation(peId, pkg, simpleName, path)
         print "Registered implementation:     id = %s" % implId
     except:
         # delete everything that was registered if anything went wrong
         requests.delete(self.registry_url + "gendef/%s" % genDefId)
         raise
Exemple #3
0
    def register_function(self, fullname, functionName, path):
        '''
        Registers a dispel4py/python function with the VERCE Registry. The function is registered under 
        'fullname' and it is identified by 'functionName'. 'path' is the path to a file containing
        the source code of the function to be registered.
        '''
        pkg, simpleName = split_name(fullname)

        # load the code
        funImpl = utils.loadSource(simpleName, path, functionName)
        funAnn = utils.extractAnnotations(funImpl)

        # build the function signature
        function = {}
        function["user"] = {'username': self.user}
        function["workspaceId"] = self.workspace
        function["pckg"] = pkg
        function["name"] = simpleName
        function["parameters"] = []
        for param in funAnn['params']:
            function["parameters"].append(param['type'] + " " + param['name'])
        function["returnType"] = funAnn['return']
        data = {}
        data["function"] = function

        print "Registering function " + simpleName + " in " + pkg
        genDefId = self.register_gendef(pkg, simpleName)
        print "Registered generic definition: id = %s" % genDefId

        # register function signature
        function["genericDefId"] = genDefId
        try:
            response = requests.post(self.registry_url + "function/",
                                     data=json.dumps(data),
                                     headers=getHeaders(self.token))
            try:
                response.raise_for_status()
            except:
                requests.delete(self.registry_url + "gendef/%s" % genDefId)
                raise RegistrationFailed, "Registration of function signature failed", sys.exc_info(
                )[2]
            functionId = response.json()["id"]
            print "Registered function signature: id = %s" % functionId
            implId = self.register_implementation(functionId, pkg, simpleName,
                                                  path)
            print "Registered implementation:     id = %s" % implId
        except:
            requests.delete(self.registry_url + "gendef/%s" % genDefId)
            raise
Exemple #4
0
 def register_function(self, fullname, functionName, path):
     '''
     Registers a dispel4py/python function with the VERCE Registry. The function is registered under 
     'fullname' and it is identified by 'functionName'. 'path' is the path to a file containing
     the source code of the function to be registered.
     '''           
     pkg, simpleName = split_name(fullname)
     
     # load the code
     funImpl = utils.loadSource(simpleName, path, functionName)
     funAnn = utils.extractAnnotations(funImpl)
     
     # build the function signature
     function = {}
     function["user"] = { 'username' : self.user }
     function["workspaceId"] = self.workspace
     function["pckg"] = pkg
     function["name"] = simpleName
     function["parameters"]=[]
     for param in funAnn['params']:
         function["parameters"].append(param['type'] + " " + param['name'])
     function["returnType"]=funAnn['return']
     data = {}
     data["function"] = function
     
     print "Registering function " + simpleName + " in " + pkg
     genDefId = self.register_gendef(pkg, simpleName)
     print "Registered generic definition: id = %s" % genDefId
     
     # register function signature
     function["genericDefId"] = genDefId
     try:
         response = requests.post(self.registry_url + "function/", data=json.dumps(data), headers=getHeaders(self.token))
         try:
             response.raise_for_status()
         except:
             requests.delete(self.registry_url + "gendef/%s" % genDefId)
             raise RegistrationFailed, "Registration of function signature failed", sys.exc_info()[2]
         functionId = response.json()["id"]
         print "Registered function signature: id = %s" % functionId
         implId = self.register_implementation(functionId, pkg, simpleName, path)
         print "Registered implementation:     id = %s" % implId
     except:
         requests.delete(self.registry_url + "gendef/%s" % genDefId)
         raise