GeoEco.ArcGIS.GeoprocessorManager.InitializeGeoprocessor

classmethod GeoprocessorManager.InitializeGeoprocessor()

Initializes the ArcGIS geoprocessor so that the GeoEco package can access ArcGIS functionality.

It is usually not necessary for methods within GeoEco to call InitializeGeoprocessor() directly. The usual pattern for implementing a GeoEco method that needs to access ArcGIS is to define a MethodMetadata for the method with the dependencies argument set to a list containing an ArcGISDependency. Then, as usual for methods that define a MethodMetadata, the method calls ValidateMethodInvocation() as its first line of code, which initializes the ArcGISDependency, which in turn calls InitializeGeoprocessor(). The method can then use GetWrappedGeoprocessor() to get the geoprocessor instance and access ArcGIS:

from GeoEco.ArcGIS import GeoprocessorManager

class MyClass(object):
    @classmethod
    def MyMethodThatAccessesArcGIS(cls):
        self.__doc__.Obj.ValidateMethodInvocation()

        # ValidateMethodInvocation() initialized the ArcGISDependency(),
        # which called InitializeGeoprocessor() for us. We can now just call
        # GetWrappedGeoprocessor().

        gp = GeoprocessorManager.GetWrappedGeoprocessor()
        gp.XXXXX(...)       # Call some geoprocessor tool or function

When using the GeoprocessorManager from a stand-alone script or other contexts that do not involve initializing a ArcGISDependency, it is necessary to call InitializeGeoprocessor() explicitly:

from GeoEco.ArcGIS import GeoprocessorManager

def MyStandAloneScript():
    GeoprocessorManager.InitializeGeoprocessor()
    gp = GeoprocessorManager.GetWrappedGeoprocessor()
    gp.XXXXX(...)       # Call some geoprocessor tool or function

if __name__ == '__main__':
    MyStandAloneScript()

If you do not want to use InitializeGeoprocessor() to instantiate the geoprocessor, you should create it yourself and call SetGeoprocessor(). GeoprocessorManager will cache a reference to your geoprocessor and use it instead. GeoprocessorManager maintains a single, interpreter-wide geoprocessor shared by all of its callers.

There is no harm in calling InitializeGeoprocessor() after it or SetGeoprocessor() has already been called. If GeoprocessorManager already has a geoprocessor, InitializeGeoprocessor() will do nothing. If you need to replace the geoprocessor that GeoprocessorManager is using, you can call SetGeoprocessor().