예제 #1
0
파일: gis_set.py 프로젝트: snakeice/grass
 def SuggestDatabase(self):
     """Suggest (set) possible GRASS Database value"""
     # only if nothing is set (<UNKNOWN> comes from init script)
     if self.GetRCValue("LOCATION_NAME") != "<UNKNOWN>":
         return
     path = get_possible_database_path()
     if path:
         try:
             self.tgisdbase.SetValue(path)
         except UnicodeDecodeError:
             # restore previous state
             # wizard gives error in this case, we just ignore
             path = None
             self.tgisdbase.SetValue(self.gisdbase)
         # if we still have path
         if path:
             self.gisdbase = path
             self.OnSetDatabase(None)
     else:
         # nothing found
         # TODO: should it be warning, hint or message?
         self._showWarning(
             _('GRASS needs a directory (GRASS database) '
               'in which to store its data. '
               'Create one now if you have not already done so. '
               'A popular choice is "grassdata", located in '
               'your home directory. '
               'Press Browse button to select the directory.'))
예제 #2
0
파일: gis_set.py 프로젝트: petrasovaa/grass
    def SuggestDatabase(self):
        """Suggest (set) possible GRASS Database value"""
        # only if nothing is set (<UNKNOWN> comes from init script)
        if self.GetRCValue("LOCATION_NAME") != "<UNKNOWN>":
            return
        path = get_possible_database_path()

        # If nothing found, try to create GRASS directory and copy startup loc
        if path is None:
            grassdb = create_database_directory()
            location = "world_latlong_wgs84"
            mapset_name = create_startup_location_in_grassdb(grassdb, location)
            if mapset_name:
                self.SetLocation(grassdb, location, mapset_name)
                self.ExitSuccessfully()

        if path:
            try:
                self.tgisdbase.SetValue(path)
            except UnicodeDecodeError:
                # restore previous state
                # wizard gives error in this case, we just ignore
                path = None
                self.tgisdbase.SetValue(self.gisdbase)
            # if we still have path
            if path:
                self.gisdbase = path
                self.OnSetDatabase(None)
        else:
            # nothing found
            # TODO: should it be warning, hint or message?
            self._showWarning(
                _('GRASS needs a directory (GRASS database) '
                  'in which to store its data. '
                  'Create one now if you have not already done so. '
                  'A popular choice is "grassdata", located in '
                  'your home directory. '
                  'Press Browse button to select the directory.'))