Skip to main content
Hello,

 

 

Our source control team asks that we use the major, minor, build, patch identifier on our FME scripts.  When they go to production they drop the patch.  So...we start with blah_1.2.0.1.fmw and when promoted to production we have blah_1.2.0.fmw.  What I'm struggling with is ensuring that the log generated for the blah_1.2.0.1.fmw is named the same; blah_1.2.0.1.fmw.  Moreover, when in production...I need the log to be named blah_1.2.0.fmw.  I've tried unsetting the log value among the workspace properties, but this only works one time in execution - i.e. the log being named the same as the script.  How do I ensure this behavior is consistent?  Note - I cannot, at this time, introduce additional flags when we call fme on the command line, nor do we allow scripts to be touched (edited) when in production...i.e. manually set the log name.

 

 

Any help or advice would be greatly appreciated.

 

 

-abe

 

Longmont, Colorado
Hi Abe,

 

 

I think there are at least two approaches.   1. Create the log file path as a Scripted Parameter

 

Define a scripted parameter to create the preferable log file path based on the current directory path and the workspace name (i.e. *.fmw file name).

 

In the script, you can access macros named "FME_MF_DIR" (current directory path) and "FME_MF_NAME" (workspace name).

 

And then, link the Workspace Parameter "Log File" to the scripted parameter.   2. Rename the log file name in the Shutdown Script

 

The log file has been closed before the shutdown process; you can get the saved log file path via a global variable named "FME_LogFileName" in the Shutdown Script.

 

So, you can create the new log file path based on "FME_LogFileName", and rename the file in the Shutdown Script.

 

 

Takashi
P.S. If the log file name is fixed (e.g. blah_1.2.0.log), you can specify the Workspace Parameter "Log File" directly like this:

 

$(FME_MF_DIR)blah_1.2.0.log

 

or

 

./blah_1.2.0.log
Thank you very much, Takashi.  This was very helpful.  (I also read your blog entry on the same topic).

 

 

Much appreciated.

 

 

-abe
Glad to know my post was helpful; and thank you for visiting my blog.

 

 

This Scripted (Python) Parameter example checks whether the workspace name contains patch identifier, and always returns the log file name without patch identifier.

 

-----

 

# Scripted (Python) Parameter Example

 

import re

 

 

# Get workspace name without extension.

 

base = re.sub('^(.+)\\\\..+$', '\\\\1', FME_MacroValuesr'FME_MF_NAME'])

 

 

# Pattern of the workspace name with patch identifier.

 

pattern = '^(.+_ 0-9]+\\\\.[0-9]+\\\\.[0-9]+)\\\\.00-9]$'

 

 

# If the workspace name matches with the pattern, remove patch identifier. if re.match(pattern, base):

 

    base = re.sub(pattern, '\\\\1', base)

 

 

# Create and return log file name without patch identifier.

 

return '%s%s.log' % (FME_MacroValues 'FME_MF_DIR'], base) -----

 

 

Tcl also can do the same thing.

 

-----

 

# Scripted (Tcl) Parameter Example

 

set base xregsub {^(.+)\\..+$} $FME_MacroValues(FME_MF_NAME) {\\1}]

 

set pattern {^(.+_>0-9]+\\.t0-9]+\\. 0-9]+)\\.90-9]$}

 

if {]regexp $pattern $base]} {

 

   set base sregsub $pattern $base {\\1}]

 

}

 

return \format "%s%s.log" $FME_MacroValues(FME_MF_DIR) $base]

 

-----

 

 

For your information.

 

I like both Python and Tcl in FME :-)

 

 

Regards,

 

Takashi
correction: if patch identifier could be 2 or more digits, the regex. (match pattern) should be: ^(.+_[0-9]+\\.[0-9]+\\.[0-9]+)\\.[0-9]+$

Reply