Stand-alone scripting and licensing question

1811
5
03-30-2012 02:10 PM
ErinIverson
New Contributor II
Is there a means to determine, when running a Python script in something like PythonWin or PyScripter, if the user already has an ArcGIS desktop license checked out and to use that license?  We have a number of floating ArcView and ArcInfo licenses, but the problem is when a user has ArcView Desktop product already open, the script will automatically snag an available ArcInfo license, leaving two licenses in use by the same user though only one is required.

I know adding "import arcview" before "import arcpy" at the beginning of the script will fix this, but then anyone running an ArcInfo Desktop application will snag an ArcView license and the problem is the same: two different concurrent licenses in use by the same user.

I want to be able to search for whichever license the user has already claimed from the concurrent license manager and to run the script using ONLY that claimed license (and any extensions it needs to check out along the way that aren't already checked out).  And all this needs to happen BEFORE importing the arcpy module, apparently. 

Thoughts?  Suggestions?  I'm stumped on how to do this before importing arcpy, since all the license checking tools seem to come along with that module and once it's imported, the 2nd licence gets grabbed.
Tags (2)
0 Kudos
5 Replies
DanPatterson_Retired
MVP Emeritus
You have to import arcpy before checking out license levels and available extensions.
0 Kudos
MathewCoyle
Frequent Contributor
I was under the assumption that Arc products and arcpy tools would share the same license and not require additional licenses to be checked out. I don't believe I have observed behaviour in my environment where two licenses would be checked out simultaneously by the same machine.
0 Kudos
ErinIverson
New Contributor II
We've definitely observed this behavior when all these criteria are met:


  • Machine is actively running an ArcView level desktop application (ArcMap or ArcCatalog, typically)

  • Machine is running stand-alone Python code using the arcpy module in PyScripter (not in the ArcView Command window, and not via ArcToolbox)

  • A concurrent ArcInfo license is available on the license server


Both the ArcView and ArcInfo license will be grabbed, one via the desktop application, and the other by PyScripter and the arcpy module.  From what we've been told, PyScripter code will actively grab the highest level ArcGIS license available, even if a lower level license is already claimed by that same user/machine.

I can't seem to find a way around this.
0 Kudos
MathewCoyle
Frequent Contributor
Ah yes, that's right if you are dealing with different levels of licenses it will. Arcpy requires an arcinfo level license for a lot of it's functionality above basic geoprocessing. Is it an option to have ArcMap default to an ArcInfo level license? If you go the other way you will have to make sure your script only requires tools from the license you are calling or below or else it will grab two regardless.
0 Kudos
MathewCoyle
Frequent Contributor
You have to import arcpy before checking out license levels and available extensions.

In regards to Dan's post, this was true prior to 10 I believe. You now need to set the license level before importing the GP

Legacy:
The product level should be set by importing the appropriate product module (arcinfo, arceditor, arcview, arcserver, arcenginegeodb, arcengine) prior to importing arcpy. The SetProduct function is a legacy function and cannot set the product once arcpy has been imported.

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z0000000z000000
0 Kudos