Solved

How to stop a workbench with a Startup Python Script

  • 13 April 2016
  • 5 replies
  • 0 views

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.macroValues['passwort']

 

if pw == "test":

 

print("PASSWORT RICHTIG")

 

else:

 

print("PASSWORT FALSCH")

___________________________

 

icon

Best answer by jdh 13 April 2016, 18:02

View original

5 replies

Badge +22

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.macroValues['passwort']

 

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

____________________________________

Badge +22

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.macroValues['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)
Userlevel 4
Badge +25

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