Esri / military-tools-geoprocessing-toolbox

military-tools-geoprocessing-toolbox is a collection of models, scripts, and tools for use in ArcGIS for Desktop and ArcGIS Pro. This toolbox is one component that is a part of Military Tools.
Apache License 2.0
33 stars 14 forks source link

Better license handling at GP tool level #395

Closed mfunk closed 5 years ago

mfunk commented 5 years ago

Military Tools requires Advanced license, but tools aren't checking for licensing.

Expected Behavior

Tools should tell user they aren't licensed before end user tries to run them.

image

Current Behavior

If installed on systems with Standard license most GP tools will run, except those that use Advanced-only components, e.g. GRG From Point and Number Features. These tools aren't validating against the license (isLicensed is not implemented or always True) .

Tools appear available...

image

But when run throw an error....

Start Time: Wednesday, January 16, 2019 9:47:20 AM
Running script NumberFeatures...
pointFeatures: C:\Users\<user>\Documents\ArcGIS\Projects\TestingMilTools2019-01\TestingMilTools2019-01.gdb\JunkPointsToNumber
outputFeatureClass: C:\Users\<user>\Documents\ArcGIS\Projects\TestingMilTools2019-01\TestingMilTools2019-01.gdb\NumFeat004
Shape type: Polygon
App environment: ARCGIS_PRO
Selecting points from <MappingLayerObject object at 0x000001E0B91D6CF0> inside of the area in_memory\areaToNumber
Selected 13 points
Sorting the selected points geographically, left to right, top to bottom
Start Time: Wednesday, January 16, 2019 9:47:21 AM
Failed to execute. Parameters are not valid.
 ERROR 000824: The tool is not licensed.
Failed to execute (Sort).
Failed at Wednesday, January 16, 2019 9:47:21 AM (Elapsed Time: 0.02 seconds)
Completed script Number Features...
 Failed to execute (NumberFeatures).
Failed at Wednesday, January 16, 2019 9:47:21 AM (Elapsed Time: 1.28 seconds)

Possible Solution

Add isLicensed to tool validation and check that correct license is available or initialized:

@staticmethod
def isLicensed():
    '''
    Check for Advanced license
    '''
    try:
        license_available = ["Available", "AlreadyInitialized"]
        if arcpy.CheckProduct("ArcInfo") in license_available:
            return True
        else:
            return False
    except Exception:
        return False

Steps to Reproduce (for bugs)

  1. Set Pro license to Standard.
  2. Try running Number Features

Context

Better up-front limitations to end user running the tools.

Your Environment

csmoore commented 5 years ago

Anyone know if there some easier way to lower the license level on Pro (single license) or do I have to deauthorize and reauthorize with another license file?

image

BobBooth commented 5 years ago

@csmoore - I think you have to have a Standard license file and authorize with it.

csmoore commented 5 years ago

Looking at this, I'm noticing many of the tools that require Advanced license or 3D extension (from table at: http://solutions.arcgis.com/defense/help/military-tools/resources/system-requirements.htm ) aren't doing this license check so will add in the missing ones in addition to GRG

csmoore commented 5 years ago

Addressed in PR #410

Should get license warning now for tools that require licenses now

For ArcMap you get the warning you expect (tool icon and when you click on tool): license2

But for Pro, it seems that you need to interact with the GP tool form before you get the error:

license-pro

BobBooth commented 5 years ago

I set two ecs test machines, to work on this, but I cannot RDP to them. I get: image.png

BobBooth commented 5 years ago

Tested on my Pro2.3 machine, using Standard license, no extensions. image

BobBooth commented 5 years ago

In ArcMap 10.3.1 with a Standard license, no extensions: The following tools have lock icons: GRG from Point Number Features Find Local Peaks Highest Points Linear Line of Sight Lowest Points Radial Line of Sight Radial Line of Sight and Range image.png

The other tools run correctly, the locked ones give you the Tool is not Licensed message. image.png

BobBooth commented 5 years ago

Tested in ArcMap on Basic, no extensions. image.png All of the tools that were expected to work with basic did, the others had lock icons.

Found that GRG from Area was expected not to work: image.png but did work. May need to update doc.

BobBooth commented 5 years ago

image.png image.png image.png image.png

Remaining tools conform to table at http://solutions.arcgis.com/defense/help/military-tools/resources/system-requirements.htm

BobBooth commented 5 years ago

Updated What's New Defense doc, Resources tab what's new, and republished the solutions pages and PDFs.

BobBooth commented 5 years ago

Submitted PR for update to Defense What is New page.

BobBooth commented 5 years ago

Doc updates showing up on stg