Exemple #1
0
    def checkMetadata(self, *args, **kwargs):
        """ Check to make sure the project directory has the necessary metadata to run this command.
        
            @note Concrete commands must call this super class method in their own
            implementation of checkMetadata(), and must call their implementation
            near the beginning of their run method.
        
        """
        super(GrassCommand, self).checkMetadata()
        self.grassMetadata = RHESSysMetadata.readGRASSEntries(self.context)

        if not 'grass_dbase' in self.metadata:
            raise MetadataException(
                "Metadata in project directory %s does not contain a GRASS Dbase"
                % (self.context.projectDir, ))
        if not 'grass_location' in self.metadata:
            raise MetadataException(
                "Metadata in project directory %s does not contain a GRASS location"
                % (self.context.projectDir, ))
        if not 'grass_mapset' in self.metadata:
            raise MetadataException(
                "Metadata in project directory %s does not contain a GRASS mapset"
                % (self.context.projectDir, ))

        self.setupGrassEnv()
Exemple #2
0
 def checkMetadata(self, *args, **kwargs):
     """ Check to make sure the project directory has the necessary metadata to run this command.
     
         @note Concrete commands must call this super class method in their own
         implementation of checkMetadata(), and must call their implementation
         near the beginning of their run method.
     
     """
     super(GrassCommand, self).checkMetadata()
     self.grassMetadata = RHESSysMetadata.readGRASSEntries(self.context)
     
     if not 'grass_dbase' in self.metadata:
         raise MetadataException("Metadata in project directory %s does not contain a GRASS Dbase" % (self.context.projectDir,)) 
     if not 'grass_location' in self.metadata:
         raise MetadataException("Metadata in project directory %s does not contain a GRASS location" % (self.context.projectDir,)) 
     if not 'grass_mapset' in self.metadata:
         raise MetadataException("Metadata in project directory %s does not contain a GRASS mapset" % (self.context.projectDir,))
     
     self.setupGrassEnv()
    action='store_true',
    required=False,
    help=
    'Overwrite existing datasets in the GRASS mapset.  If not specified, program will halt if a dataset already exists.'
)
args = parser.parse_args()
cmdline = RHESSysMetadata.getCommandLine()

configFile = None
if args.configfile:
    configFile = args.configfile

context = Context(args.projectDir, configFile)

# Check for necessary information in metadata
grassMetadata = RHESSysMetadata.readGRASSEntries(context)
if not 'landcover_rast' in grassMetadata:
    sys.exit(
        "Metadata in project directory %s does not contain a GRASS dataset with a landcover raster"
        % (context.projectDir, ))
if not 'dem_rast' in grassMetadata:
    sys.exit(
        "Metadata in project directory %s does not contain a DEM raster in a GRASS mapset"
        % (context.projectDir, ))

metadata = RHESSysMetadata.readRHESSysEntries(context)
if not 'grass_dbase' in metadata:
    sys.exit(
        "Metadata in project directory %s does not contain a GRASS Dbase" %
        (context.projectDir, ))
if not 'grass_location' in metadata:
parser.add_argument('--ignoreBurnedDEM', dest='ignoreBurnedDEM', action='store_true', required=False,
                    help='Ignore stream burned DEM, if present. Default DEM raster will be used for all operations. If not specified and if stream burned raster is present, stream burned DEM will be used for generating the flow table.')
parser.add_argument('-v', '--verbose', dest='verbose', action='store_true',
                    help='Print detailed information about what the program is doing')
args = parser.parse_args()
cmdline = RHESSysMetadata.getCommandLine()

configFile = None
if args.configfile:
    configFile = args.configfile

context = Context(args.projectDir, configFile) 

# Check for necessary information in metadata
studyArea = RHESSysMetadata.readStudyAreaEntries(context)
grassMetadata = RHESSysMetadata.readGRASSEntries(context)
metadata = RHESSysMetadata.readRHESSysEntries(context)

if not 'dem_res_x' in studyArea:
    sys.exit("Metadata in project directory %s does not contain a DEM x resolution" % (context.projectDir,))
if not 'dem_res_y' in studyArea:
    sys.exit("Metadata in project directory %s does not contain a DEM y resolution" % (context.projectDir,))

if not 'grass_dbase' in metadata:
    sys.exit("Metadata in project directory %s does not contain a GRASS Dbase" % (context.projectDir,)) 
if not 'grass_location' in metadata:
    sys.exit("Metadata in project directory %s does not contain a GRASS location" % (context.projectDir,)) 
if not 'grass_mapset' in metadata:
    sys.exit("Metadata in project directory %s does not contain a GRASS mapset" % (context.projectDir,))
if not 'rhessys_dir' in metadata:
    sys.exit("Metadata in project directory %s does not contain a RHESSys directory" % (context.projectDir,))