def validateArgs(self): argProblem = "" if self.logger is None: self.logger = utilities.logger(outDir, self.verbose) self.writetolog = self.logger.writetolog if os.path.isdir(self.inputDir): pass elif os.path.exists(self.MDSFile): if not isMDSFile(self.MDSFile): argProblem += "The supplied MDS file, " + self.MDSFile + ", does not appear to be in the appropriate format." else: argProblem += "Neither an input Directory or MDS File was supplied." if not os.path.isdir(self.outputDir): try: os.mkdir(self.outputDir) except: argProblem += 'The supplied output directory, ' + self.outputDir + ", does not exist and could not be created." if not self.format.lower() in self.driverExt.keys(): argProblem += "The supplied format must be one of " + ", ".join( self.driverExt.keys()) if argProblem: raise utilities.TrappedError( "There was a problem with one or more of the inputs to RasterFormatConverter" )
def validateArgs(self): argProblem = "" if self.logger is None: self.logger = utilities.logger(outDir, self.verbose) self.writetolog = self.logger.writetolog if os.path.isdir(self.inputDir): pass elif os.path.exists(self.MDSFile): if not isMDSFile(self.MDSFile): argProblem += "The supplied MDS file, " + self.MDSFile + ", does not appear to be in the appropriate format." else: argProblem += "Neither an input Directory or MDS File was supplied." if not os.path.isdir(self.outputDir): try: os.mkdir(self.outputDir) except: argProblem += 'The supplied output directory, ' + self.outputDir + ", does not exist and could not be created." if not self.format.lower() in self.driverExt.keys(): argProblem += "The supplied format must be one of " + ", ".join(self.driverExt.keys()) if argProblem: raise utilities.TrappedError("There was a problem with one or more of the inputs to RasterFormatConverter")
def validateInputs(self): if not os.path.exists(self.argsCSV): raise RuntimeError(self, 'Input argsFile, ' + self.argsCSV + ', could not be found on file system') if not os.path.exists(self.inputMDS): raise RuntimeError(self, 'Input MDS, ' + self.inputMDS + ', could not be found on file system') if not self.args.has_key('projectionlayers'): self.args['projectionlayers'] = '' if self.args['projectionlayers'] <> '': dirs = self.args['projectionlayers'].split(',') for dir in dirs: if not os.path.isdir(dir): raise RuntimeError(self, "Input 'projectionlayers' must be a directory") if not utilities.isMDSFile(self.inputMDS): raise RuntimeError(self, 'Input MDS, ' + self.inputMDS + ', does not appear to be formated as an MDS file.') if not os.path.exists(self.outputDir): raise RuntimeError(self, 'Output directory, ' + self.outputDir + ', could not be found on file system') if self.logger is None: self.logger = utilities.logger(outDir, self.verbose) self.writetolog = self.logger.writetolog
def validateInputs(self): # first manually set some instance variables from the args self.mdsfile = self.args_dict['c'] self.outputdir = self.args_dict['o'] self.maxent_args['outputdirectory'] = self.outputdir self.cur_processing_mode = self.args_dict['cur_processing_mode'] self.test_key = self.args_dict.get('test_key', 'test') self.sub_run = self.args_dict.get('sub_run', False) self.maxent_path = self.args_dict.get('maxent_path', "") self.java_path = self.args_dict.get('java_path', self.java_path) # next run our valid inputs checks. if not os.path.exists(self.mdsfile): raise RuntimeError(self, 'Input MDS, ' + self.mdsfile + ', could not be found on file system') if not self.maxent_args.has_key('projectionlayers'): self.maxent_args['projectionlayers'] = '' if not self.maxent_args.has_key('environmentallayers'): self.maxent_args['environmentallayers'] = '' elif self.maxent_args['environmentallayers'] != '' and \ not os.path.isdir(self.maxent_args['environmentallayers']): raise RuntimeError(self, 'Input environmentallayers directory, ' + self.maxent_args['environmentallayers'] + ', could not be found on file system') if self.maxent_args['projectionlayers'] != '': dirs = self.maxent_args['projectionlayers'].split(',') for d in dirs: if not os.path.isdir(d): raise RuntimeError(self, "Input 'projectionlayers' must be a directory") if not utilities.isMDSFile(self.mdsfile): raise RuntimeError(self, 'Input MDS, ' + self.mdsfile + ', does not appear to be formated as an MDS file.') if not os.path.exists(self.outputdir): raise RuntimeError(self, 'Output directory, ' + self.outputdir + ', could not be found on file system') if self.logger is None: self.logger = utilities.logger(self.outputdir, self.verbose) self.writetolog = self.logger.writetolog