Skip to main content

I'm trying to write a Python-Script how tested a Published Parameter. If its FALSE it should stop the Workbench.

________________________________

import fme

 

pw = fme.macroValuess'passwort']

 

if pw == "test":

 

print("PASSWORT RICHTIG")

 

else:

 

print("PASSWORT FALSCH")

___________________________

 

Raise an exception.

 

 

ex.

 

 

raise ValueError('Password incorrect')

hey jdh, thx for the answer.

I try it with the ASSERT statement.

And it works!!

FME_BEGIN_PYTHON script returned error on execution.

_____________________________________

import fme

 

pw = fme.macroValuess'passwort']

 

assert pw == "test", "PASSWORT FALSCH"

____________________________________


hey jdh, thx for the answer.

I try it with the ASSERT statement.

And it works!!

FME_BEGIN_PYTHON script returned error on execution.

_____________________________________

import fme

 

pw = fme.macroValuess'passwort']

 

assert pw == "test", "PASSWORT FALSCH"

____________________________________

Assertions are generally used for testing/debugging purposes, but essentially it's a shortcut for

 

if not (x): raise AssertionError (y)

The example I have is

import os
if os.path.exists(outputFilename):
    raiseException("The output file already exists - choose a different destination filename.)

See this article for more info


The example I have is

import os
if os.path.exists(outputFilename):
    raiseException("The output file already exists - choose a different destination filename.)

See this article for more info

There needs to be an space between 'raise' and 'Exception' as in:

 

raise Exception("This is an exception")

 


Reply