Oh no I posted without the screenshot

import subprocess
fme_ = r"E:\Program Files\FME\fme.exe"
_Workbench = r"your path to workbench\FME_option_poc.fmw"
arg1 = r"path to .gdb"
arg2 = ""
arg3 = r"your path to csv.csv"
arg4 = "Complete"
command = f'"{fme_}" "{_Workbench}" --SourceDataset_GEODATABASE_FILE "{arg1}" --False_Time "{arg2}" --DestDataset_CSV2 "{arg3}" --FME_Status_Entry "{arg4}"'
print (command)
starter = subprocess.STARTUPINFO()
starter.dwFlags |= subprocess.STARTF_USESHOWWINDOW
process = subprocess.Popen(command,startupinfo=starter, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
Here is a python function example that also retrieves the standard out and standard error messages from the workbench - advanced.
def sub__fmeworker(arg1, arg2):
""" command variable object houses the subprocess cmd string line.
1. _workbench = fme workbench.fmw, 2. arg1, 3. arg2
The subprocess.Popen() executes the command and retrieves the process outputs to stdout and stderr."""
text = ''
try:
fme_ = r"C:\Program Files\FME\fme.exe"
command = f'"{fme_}" "{_Workbench}" --FEATURE_TYPES "{arg1}" --LogFile "{arg2}"'
starter = subprocess.STARTUPINFO()
starter.dwFlags |= subprocess.STARTF_USESHOWWINDOW
process = subprocess.Popen(command,startupinfo=starter, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
if stderr:
stderr_de = str(stderr.decode("utf-8"))
msg = stderr_de.split("\r\n")[0]
text += arg1 +' '+ msg
else:
stdout_de = str(stdout.decode("utf-8"))
msg = stdout_de.split("\r\n")
text += msg+'ERROR########'
except:
text += arg1+'ERROR########'
return text
boydfme wrote:
import subprocess
fme_ = r"E:\Program Files\FME\fme.exe"
_Workbench = r"your path to workbench\FME_option_poc.fmw"
arg1 = r"path to .gdb"
arg2 = ""
arg3 = r"your path to csv.csv"
arg4 = "Complete"
command = f'"{fme_}" "{_Workbench}" --SourceDataset_GEODATABASE_FILE "{arg1}" --False_Time "{arg2}" --DestDataset_CSV2 "{arg3}" --FME_Status_Entry "{arg4}"'
print (command)
starter = subprocess.STARTUPINFO()
starter.dwFlags |= subprocess.STARTF_USESHOWWINDOW
process = subprocess.Popen(command,startupinfo=starter, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
Here is a python function example that also retrieves the standard out and standard error messages from the workbench - advanced.
def sub__fmeworker(arg1, arg2):
""" command variable object houses the subprocess cmd string line.
1. _workbench = fme workbench.fmw, 2. arg1, 3. arg2
The subprocess.Popen() executes the command and retrieves the process outputs to stdout and stderr."""
text = ''
try:
fme_ = r"C:\Program Files\FME\fme.exe"
command = f'"{fme_}" "{_Workbench}" --FEATURE_TYPES "{arg1}" --LogFile "{arg2}"'
starter = subprocess.STARTUPINFO()
starter.dwFlags |= subprocess.STARTF_USESHOWWINDOW
process = subprocess.Popen(command,startupinfo=starter, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
if stderr:
stderr_de = str(stderr.decode("utf-8"))
msg = stderr_de.split("\r\n")[0]
text += arg1 +' '+ msg
else:
stdout_de = str(stdout.decode("utf-8"))
msg = stdout_de.split("\r\n")
text += msg+'ERROR########'
except:
text += arg1+'ERROR########'
return text
Thank you!
I found the error in my code and it was in the cmd.