Skip to main content
Solved

How to stop a workbench with a Startup Python Script

  • April 13, 2016
  • 5 replies
  • 27 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")

___________________________

 

Best answer by jdh

Raise an exception.

 

 

ex.

 

 

raise ValueError('Password incorrect')
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

5 replies

jdh
Contributor
Forum|alt.badge.img+40
  • Contributor
  • Best Answer
  • April 13, 2016

Raise an exception.

 

 

ex.

 

 

raise ValueError('Password incorrect')

  • Author
  • April 13, 2016

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"

____________________________________


jdh
Contributor
Forum|alt.badge.img+40
  • Contributor
  • April 13, 2016

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)

mark2atsafe
Safer
Forum|alt.badge.img+59
  • Safer
  • April 13, 2016

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


jordimonk
  • July 11, 2017

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")