def __init__(self, parameters, service, *args, **kwargs): """Constructor initializes the Geoprocessor using :mod:`arcgisscripting` and loops thorugh all the available parameters in the Geoprocessor. Will raise an exception if problems occur with the Geoprocessor. Parameters are intended to be used in subclasses. Parameters: parameters - parameters object holding parameter information """ Tool.__init__(self, parameters) self._backend = 'arcgis' # TODO: handle the ArcGIS versions correctly try: # Inialize the logger for this tool. Logging system must be set up # before doing thishis self.logger = ArcLogger("Zupport.ArcTool", debugging=True) self.logger.debug('[%s] Acquiring geoprocessor' % service) self.gp = get_geoprocessor(10) # Set the scratch workspace explicitly to ESRI default self.gp.ScratchWorkspace = os.path.join(os.path.expanduser('~'), 'AppData', 'Local', 'Temp') except ImportError, e: self.logger.error('ArcGIS not present in the system.') sys.exit(1)
def __init__(self, parameters, service, *args, **kwargs): Tool.__init__(self, parameters, service, *args, **kwargs) self.name = self.__class__.__name__ # Identifier is a combination of the name and the class counter self.id = (self.name, PairFileiterator.id) self.log = Logger("Zupport.%s" % (self.__class__.__name__), debugging=True) self.service = service self.log.debug(msgInitSuccess)
def __init__(self, backend, parameters, *args, **kwargs): """Constructor will try to import all the necessary GDAL related modules (:mod:`osr`, :mod:`ogr`, :mod:`gdal`) and bind them as instance variables. If GDAL is not present in the system program execution will terminate. Parameters: backend - string describing the backend in use parameters - parameters object holding parameter information arclogging - boolean defining whether ArcGIS logging system is used """ Tool.__init__(self, backend, parameters, arclogging=False) # Try importing GDAL, will fail if GDAL not present try: from osgeo import osr, ogr, gdal except ImportError: self.logger.error('GDAL/OGR not present in the system.') return 1 # TODO: how does this really work? Does it mean, that each instance # has own copy or are they shared? # TODO: implement engine attribute self.osr = osr self.ogr = ogr self.gdal = gdal for parameter in args: self._parameters.append(parameter) for parameter, value in kwargs.iteritems(): self._parameters.append(value) # Check for keyword arguments if kwargs.has_key('inworkspace'): self.input = kwargs['inworkspace'] # Check for regular arguments elif len(args) > 0: self.input = args[0] # If input is defined create a workspace if self.input: self.workspace = Workspace(self.input) # Check for keyword arguments if kwargs.has_key('outworkspace'): self.output = kwargs['outworkspace'] # Check for regular arguments elif len(args) > 1: self.output = args[1]
def __init__(self, parameters, service, *args, **kwargs): Tool.__init__(self, parameters)