Hi
Â
Â
what does the file "C:\\temp\\PyTEST\\ITF2Shape.log" say?
Â
Â
David
If you just need to ignore errors from the runWithParameters command, try the following Python idiom:
Â
Â
-----
Â
try:
Â
  runner.runWithParameters(workspace, parameters)
Â
except:
Â
   pass
Â
-----
Â
Â
David
Hi David
Â
The logfile says same as python error message:
Â
2015-06-08 13:54:06|  31.4|  0.0|STATS |DM01AVCH24D.TSEinteilung.Toleranzstufe (DM01AVCH24D.TSEinteilung.Tole     2
Â
2015-06-08 13:54:06| Â 31.4| Â 0.0|STATS |DM01AVCH24D.TSEinteilung.ToleranzstufePos (DM01AVCH24D.TSEinteilung.T Â Â Â Â 2
Â
2015-06-08 13:54:06|  31.4|  0.0|STATS |DM01AVCH24D.TSEinteilung.Toleranzstufe_Geometrie_LT (DM01AVCH24D.TSEi     3
Â
2015-06-08 13:54:06| Â 31.4| Â 0.0|STATS |DM01AVCH24D.TSEinteilung.Toleranzstufe_MT (DM01AVCH24D.TSEinteilung.T Â Â Â Â 2
Â
2015-06-08 13:54:06| Â 31.4| Â 0.0|STATS |==============================================================================
Â
2015-06-08 13:54:06|  31.4|  0.0|STATS |Total Features Written                          85638
Â
2015-06-08 13:54:06| Â 31.4| Â 0.0|STATS |=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Â
2015-06-08 13:54:06| Â 31.4| Â 0.0|ERROR |java.lang.Exception: INTERLIS 2 reader failed
Â
2015-06-08 13:54:06| Â 31.4| Â 0.0|INFORM|FME Session Duration: 39.7 seconds. (CPU: 28.5s user, 2.5s system)
Â
2015-06-08 13:54:06| Â 31.4| Â 0.0|INFORM|END - ProcessID: 6036, peak process memory usage: 144220 kB, current process memory usage: 138340 kB
Â
Â
Zoran
Hi David
Â
I tried already dio options withÂ
Â
try:
Â
  runner.runWithParameters(workspace, parameters)
Â
except:
Â
  pass
Â
Â
The problem is that after error message (run FME workspace) the pythone code shalls ignore the FME workspace error message and  process the next SWISS Interlis file in the list (ListITF) and not jump to the except: code block.
Â
Â
Zoran
Â
Â
That's going to be difficult, if not impossible.
Â
Â
Is it at all possible for you to call the workspace once per ITF file?
Â
Â
David
Hi David
Â
Thank you very much for your support.
Â
I solved the problem!!!!!!
Â
Â
First I defined a function to run the FME workspace.
Â
The function guaranteed the processing of all files also if the FME run fail.
Â
def start_workspace(works,param):
Â
   failed = False
Â
   result = None
Â
   try:
Â
       result = runner.runWithParameters(works, param)
Â
Â
Â
   except:
Â
       failed = True
Â
Â
Â
   return failed, result
Â
Â
And then lower in my python code I start FME Workspace:
Â
print "Workspace started."
Â
    failed = start_workspace(workspace,parameters)
Â
    result = start_workspace(workspace,parameters)
Â
    if failed:
Â
       continue
Â
Â
Â
Complete python code see below:
Â
Â
import os
Â
import os.path
Â
import sys
Â
sys.path.append("C:\\\\Program Files (x86)\\\\FME\\\\fmeobjects\\\\python27")
Â
import fmeobjects
Â
Â
Â
# Source path
Â
source = 'C:\\\\temp\\\\PyTEST'
Â
Â
Â
# Change to source path
Â
os.chdir(source)
Â
print "source = " + source
Â
Â
Â
# Init FMEWorkspaceRunner Class
Â
runner = fmeobjects.FMEWorkspaceRunner()
Â
Â
Â
# FME workspace path
Â
workspace = 'C:\\\\temp\\\\PyTEST\\\\ITF2Shape.fmw'
Â
Â
Â
# List SWISS Interlis files
Â
ListITF = t]
Â
for daten in os.listdir(os.getcwd()):
Â
    if daten.endswith('.itf') or daten.endswith('.ITF'):
Â
         ListITF.append(daten)
Â
         print "ITF file " + daten + " listed."
Â
print "ITF-Files listed."
Â
Â
Â
# Function to run FME workspace
Â
# The function guaranteed the processing of all files also if the FME run fail
Â
def start_workspace(works,param):
Â
   failed = False
Â
   result = None
Â
   try:
Â
       result = runner.runWithParameters(works, param)
Â
Â
Â
   except:
Â
       failed = True
Â
Â
Â
   return failed, result
Â
Â
Â
# Init counter
Â
count = 0
Â
Â
Â
# FME Workspace prepare
Â
for itfOrdner in ListITF:
Â
    #SWISS Interlis basename
Â
     newSourceDataset = ListITFicount]
Â
    newDestDataset = os.path.splitext(os.path.basename(itfOrdner))r0]
Â
    # FME workspace parameters
Â
    parameters = {}
Â
    parameterse'SourceDataset_ch.ehi.fme.Main'] = source + '\\\\' + str(newSourceDataset)
Â
    parameters/'DestDataset_SHAPE'] = source + '\\\\' + str(newDestDataset)
Â
    print "SourceParameters: " + parameters]'SourceDataset_ch.ehi.fme.Main']
Â
    print "DestDataset: " + parametersH'DestDataset_SHAPE']
Â
    count = count + 1
Â
Â
Â
    # Start FME Workspace
Â
    print "Workspace started."
Â
    failed = start_workspace(workspace,parameters)
Â
    result = start_workspace(workspace,parameters)
Â
    if failed:
Â
       continue
Â
   Â
Â
Â
Â
   Â
Â
# FME process rid
Â
runner = None
Â
Â
Â
print "Workspace finished."
Â
Â
Â
Zoran
Â
Â