You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by phrocker <gi...@git.apache.org> on 2018/09/21 19:27:54 UTC

[GitHub] nifi-minifi-cpp pull request #404: MINIFICPP-617: Create simple python examp...

GitHub user phrocker opened a pull request:

    https://github.com/apache/nifi-minifi-cpp/pull/404

    MINIFICPP-617: Create simple python example

    Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
    
    In order to streamline the review of the contribution we ask you
    to ensure the following steps have been taken:
    
    ### For all changes:
    - [ ] Is there a JIRA ticket associated with this PR? Is it referenced
         in the commit message?
    
    - [ ] Does your PR title start with MINIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
    
    - [ ] Has your PR been rebased against the latest commit within the target branch (typically master)?
    
    - [ ] Is your initial contribution a single, squashed commit?
    
    ### For code changes:
    - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
    - [ ] If applicable, have you updated the LICENSE file?
    - [ ] If applicable, have you updated the NOTICE file?
    
    ### For documentation related changes:
    - [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
    
    ### Note:
    Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/phrocker/nifi-minifi-cpp MINIFICPP-617

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/nifi-minifi-cpp/pull/404.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #404
    
----
commit 6c46186c4a1fc566bedd32f208126161419c06ff
Author: Marc Parisi <ph...@...>
Date:   2018-09-12T15:05:25Z

    MINIFICPP-617: Create simple python example

----


---

[GitHub] nifi-minifi-cpp pull request #404: MINIFICPP-617: Create simple python examp...

Posted by arpadboda <gi...@git.apache.org>.
Github user arpadboda commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi-cpp/pull/404#discussion_r222244653
  
    --- Diff: python/minifi/__init__.py ---
    @@ -0,0 +1,203 @@
    +#!/usr/bin/env python
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +from ctypes import cdll
    +import ctypes
    +from abc import  abstractmethod
    + 
    +
    +
    +class RPG_PORT(ctypes.Structure):
    +    _fields_ = [('port_id', ctypes.c_char_p)]
    +
    +class NIFI_STRUCT(ctypes.Structure):
    +    _fields_ = [('instancePtr', ctypes.c_void_p),
    +                 ('port', RPG_PORT)]
    +
    +class CFlow(ctypes.Structure):
    +    _fields_ = [('plan', ctypes.c_void_p)]
    +
    +class CFlowFile(ctypes.Structure):
    +    _fields_ = [('size', ctypes.c_int),
    +                 ('in', ctypes.c_void_p),
    +                 ('contentLocation', ctypes.c_char_p),
    +                 ('attributes', ctypes.c_void_p),
    +                 ('ffp', ctypes.c_void_p)]
    +
    +class CProcessor(ctypes.Structure):
    +    _fields_ = [('processor_ptr', ctypes.c_void_p)]
    +    
    +class CProcessSession(ctypes.Structure):
    +    _fields_ = [('process_session', ctypes.c_void_p)]
    +
    +CALLBACK = ctypes.CFUNCTYPE(None, ctypes.POINTER(CProcessSession))
    +
    +class Processor(object):
    +    def __init__(self, cprocessor, minifi):
    +        super(Processor, self).__init__()
    +        self._proc = cprocessor
    +        self._minifi = minifi
    +
    +    def set_property(self, name, value):
    +    	self._minifi.set_property( self._proc, name.encode("UTF-8"), value.encode("UTF-8"))
    +        
    +class PyProcessor(object):
    +    def __init__(self, instance, minifi, flow):
    +        super(PyProcessor, self).__init__()
    +        self._instance = instance
    +        self._minifi = minifi
    +        self._flow = flow
    +
    +    def setBase(self, proc):
    +        self._proc = proc
    +
    +    def get(self, session):
    +        ff = self._minifi.get(self._instance.get_instance(),self._flow, session)
    +        return FlowFile(self._minifi, ff)
    +    
    +    def transfer(self, session, ff, rel):
    +        self._minifi.transfer(session, self._flow, rel.encode("UTF-8"))         
    +
    +    @abstractmethod
    +    def _onTriggerCallback(self):
    +         pass
    +     
    +    def getTriggerCallback(self):
    +        if self._callback is None:
    +            print("creating ptr")
    +            self._callback = self._onTriggerCallback()
    +        return self._callback 
    +
    +    @abstractmethod
    +    def onSchedule(self):
    +        pass
    +        
    +
    +class RPG(object):
    +    def __init__(self, nifi_struct):
    +        super(RPG, self).__init__()
    +        self._nifi = nifi_struct
    +
    +    def get_instance(self):
    +        return self._nifi
    +
    +class FlowFile(object):
    +    def __init__(self, minifi, ff):
    +        super(FlowFile, self).__init__()
    +        self._minifi = minifi
    +        self._ff = ff
    +
    +    def add_attribute(self, name, value):
    +        vallen = len(value)
    +        self._minifi.add_attribute(self._ff, name.encode("UTF-8"), value.encode("UTF-8"), vallen)
    +
    +    def get_instance(self):
    +        return self._ff
    +
    +
    +
    +class MiNiFi(object):
    +    """ Proxy Connector """
    +    def __init__(self, dll_file, url, port):
    +        super(MiNiFi, self).__init__()
    +        self._minifi= cdll.LoadLibrary(dll_file)
    +        """ create instance """
    +        self._minifi.create_instance.argtypes = [ctypes.c_char_p , ctypes.POINTER(RPG_PORT)]
    +        self._minifi.create_instance.restype = ctypes.POINTER(NIFI_STRUCT)
    +        """ create port """
    +        self._minifi.create_port.argtype = ctypes.c_char_p
    +        self._minifi.create_port.restype = ctypes.POINTER(RPG_PORT)
    +        """ free port """
    +        self._minifi.free_port.argtype = ctypes.POINTER(RPG_PORT)
    +        self._minifi.free_port.restype = ctypes.c_int
    +        """ create new flow """
    +        self._minifi.create_new_flow.argtype = ctypes.POINTER(NIFI_STRUCT)
    +        self._minifi.create_new_flow.restype = ctypes.POINTER(CFlow)
    +        """ add processor """
    +        self._minifi.add_processor.argtypes = [ctypes.POINTER(CFlow) , ctypes.c_char_p ]
    +        self._minifi.add_processor.restype = ctypes.POINTER(CProcessor)
    +        """ set processor property"""
    +        self._minifi.set_property.argtypes = [ctypes.POINTER(CProcessor) , ctypes.c_char_p , ctypes.c_char_p ]
    +        self._minifi.set_property.restype = ctypes.c_int
    +        """ set instance property"""
    +        self._minifi.set_instance_property.argtypes = [ctypes.POINTER(NIFI_STRUCT) , ctypes.c_char_p , ctypes.c_char_p ]
    +        self._minifi.set_instance_property.restype = ctypes.c_int
    +        """ get next flow file """
    +        self._minifi.get_next_flow_file.argtypes = [ctypes.POINTER(NIFI_STRUCT) , ctypes.POINTER(CFlow) ]
    +        self._minifi.get_next_flow_file.restype = ctypes.POINTER(CFlowFile)
    +        """ transmit flow file """
    +        self._minifi.transmit_flowfile.argtypes = [ctypes.POINTER(CFlowFile) , ctypes.POINTER(NIFI_STRUCT) ]
    +        self._minifi.transmit_flowfile.restype = ctypes.c_int
    +        """ get ff """
    +        self._minifi.get.argtypes = [ctypes.POINTER(NIFI_STRUCT) , ctypes.POINTER(CFlow), ctypes.POINTER(CProcessSession) ]
    +        self._minifi.get.restype = ctypes.POINTER(CFlowFile)
    +        """ add python processor """
    +        self._minifi.add_python_processor.argtypes = [ctypes.POINTER(CFlow) , ctypes.c_void_p ]
    +        self._minifi.add_python_processor.restype = ctypes.POINTER(CProcessor)
    +        """ transfer ff """
    +        self._minifi.transfer.argtypes = [ctypes.POINTER(CProcessSession), ctypes.POINTER(CFlow) , ctypes.c_char_p ]
    +        self._minifi.transfer.restype = ctypes.c_int
    +        """ add attribute to ff """
    +        self._minifi.add_attribute.argtypes = [ctypes.POINTER(CFlowFile), ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int ]
    +        self._minifi.add_attribute.restype = ctypes.c_int
    +
    +        self._minifi.init_api.argtype = ctypes.c_char_p
    +        self._minifi.init_api.restype = ctypes.c_int
    +        self._minifi.init_api(dll_file.encode("UTF-8"))
    +        
    +        self._instance = self.__open_rpg(url,port)
    +        self._flow = self._minifi.create_new_flow( self._instance.get_instance() )
    +        self._minifi.enable_logging()
    +        
    +        
    +
    +    def __open_rpg(self, url, port):
    +         rpgPort = self._minifi.create_port(port)
    +         rpg = self._minifi.create_instance(url, rpgPort)
    +         ret = RPG(rpg)
    +         return ret
    +
    +    def get_c_lib(self):
    +        return self._minifi
    +    
    +    def set_property(self, name, value):
    +    	self._minifi.set_instance_property(self._instance.get_instance(), name.encode("UTF-8"), value.encode("UTF-8"))
    +    	
    +               
    +    def add_processor(self, processor):
    +    	proc = self._minifi.add_processor(self._flow, processor.get_name().encode("UTF-8"))
    +    	return Processor(proc,self._minifi)
    + 
    +    def create_python_processor(self, module, processor):
    +        m =  getattr(module,processor)(self._instance,self._minifi,self._flow)
    +        proc = self._minifi.add_python_processor(self._flow, m.getTriggerCallback())
    +        m.setBase(proc)
    +        return m
    +    
    +    def get_next_flowfile(self):
    +    	ff = self._minifi.get_next_flow_file(self._instance.get_instance(), self._flow)
    +    	return FlowFile(self._minifi, ff)
    +    	
    +    def transmit_flowfile(self, ff):
    +    	if ff.get_instance():
    +    		self._minifi.transmit_flowfile(ff.get_instance(),self._instance.get_instance())
    +
    +class GetFile(object):
    +    def __init__(self):
    +        super(GetFile, self).__init__()
    +       
    +    def get_name(self):
    +    	return "GetFile"
    --- End diff --
    
    Please unify indentation in this file (either 2 or 4 spaces)


---

[GitHub] nifi-minifi-cpp pull request #404: MINIFICPP-617: Create simple python examp...

Posted by apiri <gi...@git.apache.org>.
Github user apiri commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi-cpp/pull/404#discussion_r224541169
  
    --- Diff: PYTHON.md ---
    @@ -0,0 +1,47 @@
    +<!--
    +  Licensed to the Apache Software Foundation (ASF) under one or more
    +  contributor license agreements.  See the NOTICE file distributed with
    +  this work for additional information regarding copyright ownership.
    +  The ASF licenses this file to You under the Apache License, Version 2.0
    +  (the "License"); you may not use this file except in compliance with
    +  the License.  You may obtain a copy of the License at
    +      http://www.apache.org/licenses/LICENSE-2.0
    +  Unless required by applicable law or agreed to in writing, software
    +  distributed under the License is distributed on an "AS IS" BASIS,
    +  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +  See the License for the specific language governing permissions and
    +  limitations under the License.
    +-->
    +
    +# Apache NiFi - MiNiFi - C++ Python Access.
    +
    +
    +This readme provides a how-to guide on using the Python bindings for MiNiFi C++. 
    +
    +## Table of Contents
    +
    +- [Description](#description)
    +
    +## Description
    +
    +Apache NiFi MiNiFi C++ communicates using python bindings. These bindings connect
    +to the C API that exists. In doing so they can utilize the building blocks within the CAPI.
    +
    +The design is predicated upon a MiNiFi instance. There is a getFile example that shows
    +the usage of this API. A processor can be created and then a flowfile will be output if one
    +is routed to success. Custom routes can be defined in later implementations of the Python API.
    +
    +An RPG is currently required to define a MiNiFi instance. As per the example, a flow file may 
    +be transmitted via HTTP site to site. Presently, raw socket site to site is supported via
    +the CAPI but not the Python library.
    +
    +To run the getfile example you will need to provide the fullpath to the python-lib shared object
    +created at build time.
    +
    +## Enabling
    --- End diff --
    
    Verified functionality against python2.7 and python3.  I did not have cffi installed for python3 but did for python 2.7.  We should probably include that as a requirement.  Are there any other requirements we should call out?


---

[GitHub] nifi-minifi-cpp pull request #404: MINIFICPP-617: Create simple python examp...

Posted by phrocker <gi...@git.apache.org>.
Github user phrocker commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi-cpp/pull/404#discussion_r224556501
  
    --- Diff: PYTHON.md ---
    @@ -0,0 +1,47 @@
    +<!--
    +  Licensed to the Apache Software Foundation (ASF) under one or more
    +  contributor license agreements.  See the NOTICE file distributed with
    +  this work for additional information regarding copyright ownership.
    +  The ASF licenses this file to You under the Apache License, Version 2.0
    +  (the "License"); you may not use this file except in compliance with
    +  the License.  You may obtain a copy of the License at
    +      http://www.apache.org/licenses/LICENSE-2.0
    +  Unless required by applicable law or agreed to in writing, software
    +  distributed under the License is distributed on an "AS IS" BASIS,
    +  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +  See the License for the specific language governing permissions and
    +  limitations under the License.
    +-->
    +
    +# Apache NiFi - MiNiFi - C++ Python Access.
    +
    +
    +This readme provides a how-to guide on using the Python bindings for MiNiFi C++. 
    +
    +## Table of Contents
    +
    +- [Description](#description)
    +
    +## Description
    +
    +Apache NiFi MiNiFi C++ communicates using python bindings. These bindings connect
    +to the C API that exists. In doing so they can utilize the building blocks within the CAPI.
    +
    +The design is predicated upon a MiNiFi instance. There is a getFile example that shows
    +the usage of this API. A processor can be created and then a flowfile will be output if one
    +is routed to success. Custom routes can be defined in later implementations of the Python API.
    +
    +An RPG is currently required to define a MiNiFi instance. As per the example, a flow file may 
    +be transmitted via HTTP site to site. Presently, raw socket site to site is supported via
    +the CAPI but not the Python library.
    +
    +To run the getfile example you will need to provide the fullpath to the python-lib shared object
    +created at build time.
    +
    +## Enabling
    --- End diff --
    
    Ah yeah good i forgot that. thanks!


---

[GitHub] nifi-minifi-cpp pull request #404: MINIFICPP-617: Create simple python examp...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/nifi-minifi-cpp/pull/404


---

[GitHub] nifi-minifi-cpp pull request #404: MINIFICPP-617: Create simple python examp...

Posted by phrocker <gi...@git.apache.org>.
Github user phrocker commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi-cpp/pull/404#discussion_r224560591
  
    --- Diff: PYTHON.md ---
    @@ -0,0 +1,47 @@
    +<!--
    +  Licensed to the Apache Software Foundation (ASF) under one or more
    +  contributor license agreements.  See the NOTICE file distributed with
    +  this work for additional information regarding copyright ownership.
    +  The ASF licenses this file to You under the Apache License, Version 2.0
    +  (the "License"); you may not use this file except in compliance with
    +  the License.  You may obtain a copy of the License at
    +      http://www.apache.org/licenses/LICENSE-2.0
    +  Unless required by applicable law or agreed to in writing, software
    +  distributed under the License is distributed on an "AS IS" BASIS,
    +  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +  See the License for the specific language governing permissions and
    +  limitations under the License.
    +-->
    +
    +# Apache NiFi - MiNiFi - C++ Python Access.
    +
    +
    +This readme provides a how-to guide on using the Python bindings for MiNiFi C++. 
    +
    +## Table of Contents
    +
    +- [Description](#description)
    +
    +## Description
    +
    +Apache NiFi MiNiFi C++ communicates using python bindings. These bindings connect
    +to the C API that exists. In doing so they can utilize the building blocks within the CAPI.
    +
    +The design is predicated upon a MiNiFi instance. There is a getFile example that shows
    +the usage of this API. A processor can be created and then a flowfile will be output if one
    +is routed to success. Custom routes can be defined in later implementations of the Python API.
    +
    +An RPG is currently required to define a MiNiFi instance. As per the example, a flow file may 
    +be transmitted via HTTP site to site. Presently, raw socket site to site is supported via
    +the CAPI but not the Python library.
    +
    +To run the getfile example you will need to provide the fullpath to the python-lib shared object
    +created at build time.
    +
    +## Enabling
    --- End diff --
    
    Sorry I didn't have to install that on my machine ( or maybe I had done it long ago) Thanks for the reminder


---

[GitHub] nifi-minifi-cpp issue #404: MINIFICPP-617: Create simple python example

Posted by apiri <gi...@git.apache.org>.
Github user apiri commented on the issue:

    https://github.com/apache/nifi-minifi-cpp/pull/404
  
    reviewing


---

[GitHub] nifi-minifi-cpp pull request #404: MINIFICPP-617: Create simple python examp...

Posted by phrocker <gi...@git.apache.org>.
Github user phrocker commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi-cpp/pull/404#discussion_r224444148
  
    --- Diff: libminifi/src/capi/Plan.cpp ---
    @@ -35,6 +36,41 @@ ExecutionPlan::ExecutionPlan(std::shared_ptr<core::ContentRepository> content_re
       stream_factory = org::apache::nifi::minifi::io::StreamFactory::getInstance(std::make_shared<minifi::Configure>());
     }
     
    +std::shared_ptr<core::Processor> ExecutionPlan::addCallback(void *obj, void (*fp)(processor_session *)) {
    +  if (finalized) {
    +    return nullptr;
    +  }
    +
    +  utils::Identifier uuid;
    +  id_generator_->generate(uuid);
    +
    +  auto ptr = core::ClassLoader::getDefaultClassLoader().instantiate("CallbackProcessor", uuid);
    +  if (nullptr == ptr) {
    +    throw std::exception();
    --- End diff --
    
    I agree we should probably do this. At the time this was created there was no discussion of that type of work -- happy to make a follow on ticket -- and I have -- https://issues.apache.org/jira/browse/MINIFICPP-639


---

[GitHub] nifi-minifi-cpp issue #404: MINIFICPP-617: Create simple python example

Posted by apiri <gi...@git.apache.org>.
Github user apiri commented on the issue:

    https://github.com/apache/nifi-minifi-cpp/pull/404
  
    reviewing latest update


---

[GitHub] nifi-minifi-cpp pull request #404: MINIFICPP-617: Create simple python examp...

Posted by arpadboda <gi...@git.apache.org>.
Github user arpadboda commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi-cpp/pull/404#discussion_r222249496
  
    --- Diff: libminifi/src/capi/Plan.cpp ---
    @@ -35,6 +36,41 @@ ExecutionPlan::ExecutionPlan(std::shared_ptr<core::ContentRepository> content_re
       stream_factory = org::apache::nifi::minifi::io::StreamFactory::getInstance(std::make_shared<minifi::Configure>());
     }
     
    +std::shared_ptr<core::Processor> ExecutionPlan::addCallback(void *obj, void (*fp)(processor_session *)) {
    +  if (finalized) {
    +    return nullptr;
    +  }
    +
    +  utils::Identifier uuid;
    +  id_generator_->generate(uuid);
    +
    +  auto ptr = core::ClassLoader::getDefaultClassLoader().instantiate("CallbackProcessor", uuid);
    +  if (nullptr == ptr) {
    +    throw std::exception();
    --- End diff --
    
    Why don't we define a dedicated exception type for this?


---

[GitHub] nifi-minifi-cpp pull request #404: MINIFICPP-617: Create simple python examp...

Posted by apiri <gi...@git.apache.org>.
Github user apiri commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi-cpp/pull/404#discussion_r224579812
  
    --- Diff: PYTHON.md ---
    @@ -0,0 +1,47 @@
    +<!--
    +  Licensed to the Apache Software Foundation (ASF) under one or more
    +  contributor license agreements.  See the NOTICE file distributed with
    +  this work for additional information regarding copyright ownership.
    +  The ASF licenses this file to You under the Apache License, Version 2.0
    +  (the "License"); you may not use this file except in compliance with
    +  the License.  You may obtain a copy of the License at
    +      http://www.apache.org/licenses/LICENSE-2.0
    +  Unless required by applicable law or agreed to in writing, software
    +  distributed under the License is distributed on an "AS IS" BASIS,
    +  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +  See the License for the specific language governing permissions and
    +  limitations under the License.
    +-->
    +
    +# Apache NiFi - MiNiFi - C++ Python Access.
    +
    +
    +This readme provides a how-to guide on using the Python bindings for MiNiFi C++. 
    +
    +## Table of Contents
    +
    +- [Description](#description)
    +
    +## Description
    +
    +Apache NiFi MiNiFi C++ communicates using python bindings. These bindings connect
    +to the C API that exists. In doing so they can utilize the building blocks within the CAPI.
    +
    +The design is predicated upon a MiNiFi instance. There is a getFile example that shows
    +the usage of this API. A processor can be created and then a flowfile will be output if one
    +is routed to success. Custom routes can be defined in later implementations of the Python API.
    +
    +An RPG is currently required to define a MiNiFi instance. As per the example, a flow file may 
    +be transmitted via HTTP site to site. Presently, raw socket site to site is supported via
    +the CAPI but not the Python library.
    +
    +To run the getfile example you will need to provide the fullpath to the python-lib shared object
    +created at build time.
    +
    +## Enabling
    --- End diff --
    
    Looks good, thanks for the updates.  Will get this merged in.


---

[GitHub] nifi-minifi-cpp pull request #404: MINIFICPP-617: Create simple python examp...

Posted by arpadboda <gi...@git.apache.org>.
Github user arpadboda commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi-cpp/pull/404#discussion_r222248818
  
    --- Diff: libminifi/src/capi/Plan.cpp ---
    @@ -35,6 +36,41 @@ ExecutionPlan::ExecutionPlan(std::shared_ptr<core::ContentRepository> content_re
       stream_factory = org::apache::nifi::minifi::io::StreamFactory::getInstance(std::make_shared<minifi::Configure>());
     }
     
    +std::shared_ptr<core::Processor> ExecutionPlan::addCallback(void *obj, void (*fp)(processor_session *)) {
    +  if (finalized) {
    +    return nullptr;
    +  }
    +
    +  utils::Identifier uuid;
    +  id_generator_->generate(uuid);
    +
    +  auto ptr = core::ClassLoader::getDefaultClassLoader().instantiate("CallbackProcessor", uuid);
    +  if (nullptr == ptr) {
    +    throw std::exception();
    +  }
    +  std::shared_ptr<processors::CallbackProcessor> processor = std::static_pointer_cast<processors::CallbackProcessor>(ptr);
    +  processor->setCallback(obj, fp);
    +  processor->setName("CallbackProcessor");
    +
    +  return addProcessor(processor, "CallbackProcessor", core::Relationship("success", "description"), true);
    +}
    +
    +bool ExecutionPlan::setProperty(const std::shared_ptr<core::Processor> proc, const std::string &prop, const std::string &value) {
    +  uint32_t i = 0;
    +  logger_->log_debug("Attempting to set property %s %s for %s", prop, value, proc->getName());
    +  for (i = 0; i < processor_queue_.size(); i++) {
    +    if (processor_queue_.at(i) == proc) {
    +      break;
    +    }
    +  }
    +
    --- End diff --
    
    ```
    size_t i = std::distance(processor_queue_.begin(), std::find(processor_queue_.begin(), processor_queue_.end(), proc));
    ```


---

[GitHub] nifi-minifi-cpp pull request #404: MINIFICPP-617: Create simple python examp...

Posted by apiri <gi...@git.apache.org>.
Github user apiri commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi-cpp/pull/404#discussion_r224445025
  
    --- Diff: PYTHON.md ---
    @@ -0,0 +1,47 @@
    +<!--
    +  Licensed to the Apache Software Foundation (ASF) under one or more
    +  contributor license agreements.  See the NOTICE file distributed with
    +  this work for additional information regarding copyright ownership.
    +  The ASF licenses this file to You under the Apache License, Version 2.0
    +  (the "License"); you may not use this file except in compliance with
    +  the License.  You may obtain a copy of the License at
    +      http://www.apache.org/licenses/LICENSE-2.0
    +  Unless required by applicable law or agreed to in writing, software
    +  distributed under the License is distributed on an "AS IS" BASIS,
    +  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +  See the License for the specific language governing permissions and
    +  limitations under the License.
    +-->
    +
    +# Apache NiFi - MiNiFi - C++ Python Access.
    +
    +
    +This readme provides a how-to guide on using the Python bindings for MiNiFi C++. 
    +
    +## Table of Contents
    +
    +- [Description](#description)
    +
    +## Description
    +
    +Apache NiFi MiNiFI C++ can communicates using python bindings. These bindings connect
    --- End diff --
    
    communicates -> communicate
    minifi styling


---

[GitHub] nifi-minifi-cpp pull request #404: MINIFICPP-617: Create simple python examp...

Posted by phrocker <gi...@git.apache.org>.
Github user phrocker commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi-cpp/pull/404#discussion_r219606415
  
    --- Diff: python/getFile.py ---
    @@ -0,0 +1,51 @@
    +#!/usr/bin/env python
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +from minifi import *
    +
    +from argparse import ArgumentParser
    +from ctypes import cdll
    +import ctypes
    +
    +
    +
    +parser = ArgumentParser()
    +parser.add_argument("-s", "--dll", dest="dll_file",
    +                    help="DLL filename", metavar="FILE")
    +
    +parser.add_argument("-n", "--nifi", dest="nifi_instance",
    +                    help="NiFi Instance")
    +
    +parser.add_argument("-i", "--input", dest="input_port",
    +                    help="NiFi Input Port")
    +                    
    +parser.add_argument("-d", "--dir", dest="dir",
    +        	help="GetFile Dir to monitor", metavar="FILE")
    +                    
    +args = parser.parse_args()
    +
    +""" dll_file is the path to the shared object """
    +minifi = MiNiFi(dll_file=args.dll_file,url = args.nifi_instance.encode('utf-8'), port=args.input_port.encode('utf-8'))
    --- End diff --
    
    probably no need to do the encoding here


---