Control license behavior in a Python toolbox

The isLicensed method is an optional validation method that checks if a tool in a Python toolbox is licensed to execute. It can be used to restrict the tool from being run if the appropriate licenses and extensions required to run other geoprocessing tools used by the Python toolbox tool are not available.

If the isLicensed method returns False, the tool cannot be run. If the method returns True or the method is not used, the tool can be run.

def isLicensed(self):
    """Allow the tool to run, only if the ArcGIS 3D Analyst extension 
    is available."""
        if arcpy.CheckExtension("3D") != "Available":
            raise Exception
    except Exception:
        return False  # The tool cannot be run

    return True  # The tool can be run

Verwandte Themen