Пример #1
0
import os
import sys
import glob
import math
import tempfile
import copy
import time
import traceback

gbase = os.getenv("GISBASE")
pypath = os.path.join(gbase, 'etc', 'wxpython', 'gui_modules')
sys.path.append(pypath)

import globalvar
if not os.getenv("GRASS_WXBUNDLED"):
    globalvar.CheckForWx()
import wx
import wx.aui

try:
    import subprocess
except:
    CompatPath = os.path.join(globalvar.ETCWXDIR)
    sys.path.append(CompatPath)
    from compat import subprocess

gmpath = os.path.join(globalvar.ETCWXDIR, "icons")
sys.path.append(gmpath)

grassPath = os.path.join(globalvar.ETCDIR, "python")
sys.path.append(grassPath)
Пример #2
0
def main(argv=None):
    """ Main. Calls either GUI or CLI, depending on arguments provided. """
    #@FIXME: solve this double ifelse. the control should not be done twice.

    controller = Controller()

    if argv is None:
        importR()
        argv = sys.argv[
            1:]  # stripping first item, the full name of this script
        # wxGUI call
        import globalvar
        if not os.getenv("GRASS_WXBUNDLED"):
            globalvar.CheckForWx()
        import vkrige as GUI

        import wx

        app = wx.App()
        KrigingFrame = GUI.KrigingModule(parent=None,
                                         Rinstance=robjects,
                                         controller=controller)
        KrigingFrame.Centre()
        KrigingFrame.Show()
        app.MainLoop()

    else:
        #CLI
        options, flags = argv
        #@TODO: Work on verbosity. Sometimes it's too verbose (R), sometimes not enough.
        if grass.find_file(options['input'],
                           element='vector')['fullname'] is '':
            grass.fatal(_("option: <input>: Vector map not found.")
                        )  #TODO cosmetics, insert real map name

        #@TODO: elaborate input string, if contains mapset or not.. thanks again to Bob for testing on 64bit.

        # create output map name, if not specified
        if options['output'] is '':
            try:  # to strip mapset name from fullname. Ugh.
                options['input'] = options['input'].split("@")[0]
            except:
                pass
            options['output'] = options['input'] + '_kriging'

        # check for output map with same name. g.parser can't handle this, afaik.
        if grass.find_file(options['output'],
                           element='cell')['fullname'] and os.getenv(
                               "GRASS_OVERWRITE") == None:
            grass.fatal(_("option: <output>: Raster map already exists."))
        if options['output_var'] is not '' and (
                grass.find_file(options['output_var'],
                                element='cell')['fullname']
                and os.getenv("GRASS_OVERWRITE") == None):
            grass.fatal(
                _("option: <output>: Variance raster map already exists."))

        importR()
        if options['model'] is '':
            #@FIXME does not catch error.
            try:
                robjects.r.require("automap")
            except ImportError, e:
                grass.fatal(
                    _("R package automap is missing, no variogram autofit available."
                      ))
        else: