03-22-2020 06:55 PM
I have a parent pipeline calling another. Which runs successfully when you validate but errors when you execute. Why is this? It seems that the issue is coming form a pyton script in the child pipeline. The purpose of the script is the call a bat.file on a server and wait for the .bat file to complete and return the error message if any before the pipleline completes. If i validate the parent pipeline it calls the child pipeline and execute this script without issues but this is not the case when i execute. I am either getting an error saying on the script snap “Input not completely consumed” or other times “root pipeline no longer running”
the following is the script code
from com.snaplogic.scripting.language import ScriptHook
import java.util, os, subprocess
class TransformScript(ScriptHook):
def init(self, input, output, error, log):
self.input = input
self.output = output
self.error = error
self.log = log
# The "execute()" method is called once when the pipeline is started
# and allowed to process its inputs or just send data to its outputs.
def execute(self):
filepath="C:\\Profisee\\ProfiseeMatch.bat & exit"
p = subprocess.Popen(filepath, shell=True, stdout = subprocess.PIPE)
p.communicate()
p.wait()
self.output.write (p.returncode)
hook = TransformScript(input, output, error, log)
Any ideas what may be causing this and how this can be solved?
03-25-2020 03:58 PM
See the example python script in the doc page https://docs-snaplogic.atlassian.net/wiki/spaces/SD/pages/1439321/Script
The script needs to consume all the input documents which are passed in its input view. If you do not need the input docs, you could add a loop to drop the docs
def execute(self):
while self.input.hasNext():
data = self.input.next()
filepath="C:\\Profisee\\ProfiseeMatch.bat & exit"
p = subprocess.Popen(filepath, shell=True, stdout = subprocess.PIPE)
p.communicate()
p.wait()
self.output.write (p.returncode)