Skip to main content
Question

Get the workbench title to use within a Python Script

  • January 9, 2013
  • 2 replies
  • 49 views

Forum|alt.badge.img
Hello,

 

 

I notice that FME Server displays in the Repositories TAb the Workbench Title and Description etc, is there a way to get these attributes to use in a Python script within the Workbench?

 

 

I want to email via FME Server Notifier that the workbench 'its name' is failed or succeeded.

 

 

Cheers,

 

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.

2 replies

david_r
Celebrity
  • January 10, 2013
Have a look at the variable FME_MacroValues['WORKSPACE_NAME'], it will return the filename of the current workspace, without the fmw extension.

 

 

To see what is available in the FME_MacroValues dictionary, try the following in a PythonCaller:

 

 

import fmeobjects import pprint   def showAllMacroValues(feature):     pp = pprint.PrettyPrinter(indent=4)     pp.pprint(FME_MacroValues)

takashi
Celebrity
  • January 14, 2013
Hi Goochy,   I think there is no simple way, but FMW file contains each Workspace Property as a text line, form of the line is: #! <Tag>="<Value>" So, if the FMW file path of the target workspace can be clear, we can get Workspace Properties from the file.

 

The following script would get Title and Last Save Date from "C:\\test.fmw", for example.   ----- import re, os   # Define regular expressions (patterns) to find properties

 

# and change each pattern to Regular Expression Object. regex = {     'Title': '^#! TITLE="([^"]*)"$',     'Last Save Date': '^#! LAST_SAVE_DATE="([^"]*)"$' } for name in regex: regex[name] = re.compile(regex[name])   # Set FMW file path of the target workspace. fmwPath = 'C:\\\\test.fmw'   # Get properties from the file. property = {} if os.path.exists(fmwPath):     for line in [line.rstrip() for line in open(fmwPath)]:         for name in regex:             match = regex[name].search(line)             if match: property[name] = match.group(1)   # Use properties. for name in property:     print '%s: %s' % (name, property[name]) -----   Oh, it'll be useless if the specification of FMW file format was changed...