Question

Python and Available Licences

  • 8 October 2013
  • 4 replies
  • 3 views

Badge
Hi ...

 

 

How can I check the availablily of an FME license using python?

 

 

I want to make sure a license is available before executing a series of arcgis and fme steps.

 

 

I think I've seen it somewhere on fmepedia before but I can't find the thread now.

 

 

Ken

 

 


4 replies

Userlevel 2
Badge +17
Hi,

 

 

fmeobjects.FMELicenseManager object might help you.

 

Try this example. -----

 

# Example of FMELicenseManager (Startup Python Script) import fmeobjects   # Create FMELicenseManager object. licMan = fmeobjects.FMELicenseManager()   # Print FME license type. print 'FME License Type :', licMan.getLicenseType()   # FME license property names.

 

# See more in your "<FME>/licenses/fme_license.fmelic" file. # <FME>: FME home directory = "C:/Program Files/FME" by default. propNames = [ 'REPROJECT', 'BASIC_RASTER', 'PRODUCT NAME', 'EXPIRY DATE', 'LICENSE TYPE', 'LICENSE CATEGORY', ]   # Print FME license properties. for name in propNames:     prop = licMan.getLicenseProperty(name)     if prop:         print name, ':', prop

 

  # Destroy FMELicenseManager object.

 

# It's not necessary in PythonCreator or PythonCaller.

 

# In Startup / Shutdown?

 

del licMan -----

 

About the "del" statement above, we are discussing just now. Follow up this thread. May I use FME Objects in Startup / Shutdown Python Script? http://fmepedia.safe.com/AnswersQuestionDetail?id=906a0000000cq6iAAA   I always refer to "FME Object Python API" documentation when writing Python scripts for FME. There isn't this documentation in FMEpedea. It has been installed into your machine if you selected "Install the SDK" when installing FME.

 

See here. <FME>/fmeobjects/python/apidoc/index.html * <FME>: FME home directory = "C:/Program Files/FME" by default.

 

 

Takashi
Badge
Thx for the reply Takashi.

 

 

Is this a stand alone python script? 

 

 

I want to check the availability of a FME license in a stand along python script and not in  a startup or shutdown script in workbench.

 

 

Userlevel 2
Badge +17
The script can not be executed in a "complete" standalone environment., because it imports fmeobjects module (FME Objects Python API).

 

On the machine in which FME was installed, you can run the script using not only FME (Startup) but an external Python environment, after installing fmeobjects module into the Python environment.

 

 

Assume that you are using FME 2013 on Windows, and Python 2.7 has been already installed in your machine; to install fmeobjects into the external Python 2.7, just copy this dynamic module file

 

<FME>\\fmeobjects\\python27\\fmeobjects.pyd

 

to here.

 

<Python27>\\Lib\\site-packages\\fmeobjects.pyd

 

 

<FME> is FME home directory ("C:\\Program Files\\FME" by default), <Python27> is Python 2.7 home directory ("C:\\Python27" by default).
Userlevel 2
Badge +17
Alternatively, you can also append module searching path before importing fmeobjects module in the script. In this case, you don't need to copy "fmeobjects.pyd" to the external Python environment.

 

-----

 

# UsingFMEObjects.py

 

import sys

 

sys.path.append("C:\\\\Program Files\\\\FME\\\\fmeobjects\\\\python27")

 

import fmeobjects

 

...

 

-----

Reply