Exemplo n.º 1
0
    def __init__(self,
                 ltype,
                 cmd,
                 Map,
                 name=None,
                 active=True,
                 hidden=False,
                 opacity=1.0):
        """!Create new instance

        @todo pass cmd as tuple instead of list

        @param ltype layer type ('raster', 'vector', 'overlay', 'command', etc.)
        @param cmd GRASS command to render layer,
        given as list, e.g. ['d.rast', 'map=elevation@PERMANENT']
        @param Map render.Map instance
        @param name layer name, e.g. 'elevation@PERMANENT' (for layer tree)
        @param active layer is active, will be rendered only if True
        @param hidden layer is hidden, won't be listed in Layer Manager if True
        @param opacity layer opacity <0;1>
        """

        # generated file for each layer
        if USE_GPNMCOMP or ltype == 'overlay':
            tmpfile = tempfile.mkstemp()[1]
            self.maskfile = tmpfile + '.pgm'
            if ltype == 'overlay':
                self.mapfile = tmpfile + '.png'
            else:
                self.mapfile = tmpfile + '.ppm'
            grass.try_remove(tmpfile)
        else:
            self.mapfile = self.maskfile = None

        # stores class which manages rendering instead of simple command - e. g. wms
        self.renderMgr = None

        self.Map = Map
        self.type = None
        self.SetType(ltype)
        self.name = name

        if self.type == 'command':
            self.cmd = list()
            for c in cmd:
                self.cmd.append(utils.CmdToTuple(c))
        else:
            self.cmd = utils.CmdToTuple(cmd)

        self.active = active
        self.hidden = hidden
        self.opacity = opacity

        self.forceRender = True

        Debug.msg(
            3, "Layer.__init__(): type=%s, cmd='%s', name=%s, "
            "active=%d, opacity=%d, hidden=%d" %
            (self.type, self.GetCmd(string=True), self.name, self.active,
             self.opacity, self.hidden))
Exemplo n.º 2
0
def main():
    out = options['output']
    wfs_url = options['url']

    tmp = grass.tempfile()
    tmpxml = tmp + '.xml'

    grass.message(_("Retrieving data..."))
    inf = urllib.urlopen(wfs_url)
    outf = file(tmpxml, 'wb')
    while True:
	s = inf.read()
	if not s:
	    break
	outf.write(s)
    inf.close()
    outf.close()

    grass.message(_("Importing data..."))
    ret = grass.run_command('v.in.ogr', flags = 'o', dsn = tmpxml, out = out)
    grass.try_remove(tmpxml)
    
    if ret == 0:
        grass.message(_("Vector points map <%s> imported from WFS.") % out)
    else:
        grass.message(_("WFS import failed"))
Exemplo n.º 3
0
 def _renderCmdFile(self, force, windres):
     if not force:
         return ([self.mapfileCmd],
                 [self.maskfileCmd],
                 ['1.0'])
     
     region = os.environ["GRASS_REGION"] = self.SetRegion(windres)
     self._writeEnvFile({'GRASS_REGION' : region})
     currMon = grass.gisenv()['MONITOR']
     if currMon != self.monitor:
         gcmd.RunCommand('g.gisenv',
                         set = 'MONITOR=%s' % self.monitor)
     
     grass.try_remove(self.mapfileCmd) # GRASS_PNG_READ is TRUE
     
     nlayers = self._parseCmdFile()
     
     if currMon != self.monitor:
         gcmd.RunCommand('g.gisenv',
                         set = 'MONITOR=%s' % currMon)
         
     if nlayers > 0:
         return ([self.mapfileCmd],
                 [self.maskfileCmd],
                 ['1.0'])
     else:
         return ([], [], [])
Exemplo n.º 4
0
 def _clean(self, llist):
     for layer in llist:
         if layer.maskfile:
             grass.try_remove(layer.maskfile)
         if layer.mapfile:
             grass.try_remove(layer.mapfile)
         llist.remove(layer)
Exemplo n.º 5
0
 def OnExit(self):
     if __name__ == "__main__":
         # stop the timer
         # self.timer.Stop()
         # terminate thread
         for f in monFile.itervalues():
             grass.try_remove(f)
Exemplo n.º 6
0
 def OnExit(self):
     if __name__ == "__main__":
         # stop the timer
         # self.timer.Stop()
         # terminate thread
         for f in monFile.itervalues():
             grass.try_remove(f)
Exemplo n.º 7
0
 def _clean(self, llist):
     for layer in llist:
         if layer.maskfile:
             grass.try_remove(layer.maskfile)
         if layer.mapfile:
             grass.try_remove(layer.mapfile)
         llist.remove(layer)
Exemplo n.º 8
0
def remove_extension():
    # is module available?
    bin_dir = os.path.join(options['prefix'], 'bin', options['extension'])
    scr_dir = os.path.join(options['prefix'], 'scripts', options['extension'])
    if not os.path.exists(bin_dir) and not os.path.exists(scr_dir):
        grass.fatal(_("Module <%s> not found") % options['extension'])
    
    for f in [bin_dir, scr_dir,
              os.path.join(options['prefix'], 'docs', 'html', options['extension'] + '.html'),
              os.path.join(options['prefix'], 'man', 'man1', options['extension'] + '.1')]:
        grass.try_remove(f)
    
    grass.message(_("Module <%s> successfully uninstalled") % options['extension'])
Exemplo n.º 9
0
 def __init__(self, type, cmd, name = None,
              active = True, hidden = False, opacity = 1.0):
     """!Create new instance
     
     @todo pass cmd as tuple instead of list
     
     @param type layer type ('raster', 'vector', 'overlay', 'command', etc.)
     @param cmd GRASS command to render layer,
     given as list, e.g. ['d.rast', 'map=elevation@PERMANENT']
     @param name layer name, e.g. 'elevation@PERMANENT' (for layer tree)
     @param active layer is active, will be rendered only if True
     @param hidden layer is hidden, won't be listed in Layer Manager if True
     @param opacity layer opacity <0;1>
     """
     self.type  = type
     self.name  = name
     
     if self.type == 'command':
         self.cmd = list()
         for c in cmd:
             self.cmd.append(utils.CmdToTuple(c))
     else:
         self.cmd = utils.CmdToTuple(cmd)
     
     self.active  = active
     self.hidden  = hidden
     self.opacity = opacity
     
     self.force_render = True
     
     Debug.msg (3, "Layer.__init__(): type=%s, cmd='%s', name=%s, " \
                    "active=%d, opacity=%d, hidden=%d" % \
                    (self.type, self.GetCmd(string = True), self.name, self.active,
                     self.opacity, self.hidden))
     
     # generated file for each layer
     if USE_GPNMCOMP or self.type == 'overlay':
         tmpfile = tempfile.mkstemp()[1]
         self.maskfile = tmpfile + '.pgm'
         if self.type == 'overlay':
             self.mapfile  = tmpfile + '.png'
         else:
             self.mapfile  = tmpfile + '.ppm'
         grass.try_remove(tmpfile)
     else:
         self.mapfile = self.maskfile = None
Exemplo n.º 10
0
def cleanup():
    grass.try_remove('spectrum.gnuplot')
    for name in glob.glob('data_[0-9]*'):
	if name[5:].isdigit():
	   grass.try_remove(name)

    grass.try_remove('data_x')
    for name in glob.glob('data_y_[0-9]*'):
	if name[7:].isdigit():
	   grass.try_remove(name)
Exemplo n.º 11
0
def main():
    input = options['input']
    format = options['format']
    dsn = options['dsn']
    table = options['table']

    if format.lower() == 'dbf':
	format = "ESRI_Shapefile"

    if format.lower() == 'csv':
	olayer = grass.basename(dsn, 'csv')
    else:
	olayer = None

    #is there a simpler way of testing for --overwrite?
    dbffile = input + '.dbf'
    if os.path.exists(dbffile) and not grass.overwrite():
	grass.fatal(_("File <%s> already exists") % dbffile)

    if olayer:
	if grass.run_command('v.out.ogr', quiet = True, input = input, dsn = dsn,
			     format = format, type = 'point', olayer = olayer) != 0:
	    sys.exit(1)
    else:
	if grass.run_command('v.out.ogr', quiet = True, input = input, dsn = dsn,
			     format = format, type = 'point') != 0:
	    sys.exit(1)

    if format == "ESRI_Shapefile":
	exts = ['shp', 'shx', 'prj']
	if dsn.endswith('.dbf'):
	    outname = grass.basename(dsn, 'dbf')
	    for ext in exts:
		grass.try_remove("%s.%s" % (outname, ext))
	    outname += '.dbf'
	else:
	    for ext in exts:
		grass.try_remove(os.path.join(dsn, "%s.%s" % (input, ext)))
	    outname = os.path.join(dsn, input + ".dbf")
    elif format.lower() == 'csv':
	outname = dsn + '.csv'
    else:
	outname = input

    grass.message(_("Exported table <%s>") % outname)
Exemplo n.º 12
0
    def _parseCmdFile(self):
        """!Parse cmd file for standalone application
        """
        nlayers = 0
        try:
            fd = open(self.cmdfile, 'r')
            grass.try_remove(self.mapfile)
            cmdLines = fd.readlines()
            gcmd.RunCommand('g.gisenv',
                            set = 'MONITOR_%s_CMDFILE=' % self.monitor)
            
            for cmd in cmdLines:
                cmdStr = cmd.strip().split(' ')
                cmd = utils.CmdToTuple(cmdStr)

                gcmd.RunCommand(cmd[0], **cmd[1])
                nlayers += 1

            gcmd.RunCommand('g.gisenv',
                            set = 'MONITOR_%s_CMDFILE=%s' % (self.monitor, self.cmdfile))
        except IOError, e:
            grass.warning(_("Unable to read cmdfile '%(cmd)s'. Details: %(det)s") % \
                              { 'cmd' : self.cmdfile, 'det' : e })
            return
Exemplo n.º 13
0
    def Render(self):
        """!Render layer to image
        
        @return rendered image filename
        @return None on error or if cmdfile is defined
        """
        if not self.cmd:
            return None
        
        # ignore in 2D
        if self.type == '3d-raster':
            return None
        
        Debug.msg (3, "Layer.Render(): type=%s, name=%s" % \
                       (self.type, self.name))
        
        # prepare command for each layer
        layertypes = ('raster', 'rgb', 'his', 'shaded', 'rastarrow', 'rastnum',
                      'vector','thememap','themechart',
                      'grid', 'geodesic', 'rhumb', 'labels',
                      'command', 'rastleg','maplegend',
                      'overlay')
        
        if self.type not in layertypes:
            raise gcmd.GException(_("<%(name)s>: layer type <%(type)s> is not supported") % \
                                      {'type' : self.type, 'name' : self.name})
        
        # start monitor
	if self.mapfile:
	    os.environ["GRASS_PNGFILE"] = self.mapfile
        
        # execute command
        try:
            if self.type == 'command':
                read = False
                for c in self.cmd:
                    ret, msg = gcmd.RunCommand(c[0],
                                          getErrorMsg = True,
                                          quiet = True,
                                          **c[1])
                    if ret != 0:
                        break
                    if not read:
                        os.environ["GRASS_PNG_READ"] = "TRUE"
                
                os.environ["GRASS_PNG_READ"] = "FALSE"
            else:
                ret, msg = gcmd.RunCommand(self.cmd[0],
                                           getErrorMsg = True,
                                           quiet = True,
                                           **self.cmd[1])
                
            if msg:
                sys.stderr.write(_("Command '%s' failed\n") % self.GetCmd(string = True))
                sys.stderr.write(_("Details: %s\n") % msg)
            if ret != 0:
                raise gcmd.GException()
        
        except gcmd.GException:
            # clean up after problems
            for f in [self.mapfile, self.maskfile]:
                if not f:
                    continue
                grass.try_remove(f)
                f = None
        
        # stop monitor
        if self.mapfile and "GRASS_PNGFILE" in os.environ:
            del os.environ["GRASS_PNGFILE"]
        
        self.force_render = False
        
        return self.mapfile
Exemplo n.º 14
0
    def Render(self):
        """!Render layer to image

        @return rendered image filename
        @return None on error or if cmdfile is defined
        """
        if not self.cmd:
            return None

        # ignore in 2D
        if self.type == "3d-raster":
            return None

        Debug.msg(3, "Layer.Render(): type=%s, name=%s" % (self.type, self.name))

        # prepare command for each layer
        layertypes = utils.command2ltype.values() + ["overlay", "command"]

        if self.type not in layertypes:
            raise GException(
                _("<%(name)s>: layer type <%(type)s> is not supported")
                % {"type": self.type, "name": self.name}
            )

        if self.mapfile:
            os.environ["GRASS_RENDER_FILE"] = self.mapfile

        # execute command
        try:
            if self.type == "command":
                read = False
                for c in self.cmd:
                    ret, msg = self._runCommand(c)
                    if ret != 0:
                        break
                    if not read:
                        os.environ["GRASS_RENDER_FILE_READ"] = "TRUE"

                os.environ["GRASS_RENDER_FILE_READ"] = "FALSE"
            else:
                ret, msg = self._runCommand(self.cmd)
            if ret != 0:
                sys.stderr.write(_("Command '%s' failed\n") % self.GetCmd(string=True))
                if msg:
                    sys.stderr.write(_("Details: %s\n") % msg)
                raise GException()

        except GException:
            # clean up after problems
            for f in [self.mapfile, self.maskfile]:
                if not f:
                    continue
                grass.try_remove(f)
                f = None

        # stop monitor
        if self.mapfile and "GRASS_RENDER_FILE" in os.environ:
            del os.environ["GRASS_RENDER_FILE"]

        self.forceRender = False

        return self.mapfile
Exemplo n.º 15
0
def cleanup():
    for ext in ['', '.sort']:
        grass.try_remove(tmp + ext)
Exemplo n.º 16
0
def main():
    fileorig = options['input']
    filevect = options['output']
    
    if not filevect:
	filevect = grass.basename(fileorig, 'txt')

    #are we in LatLong location?
    s = grass.read_command("g.proj", flags='j')
    kv = grass.parse_key_val(s)
    if kv['+proj'] != 'longlat':
	grass.fatal(_("This module only operates in LatLong/WGS84 locations"))

    #### setup temporary file
    tmpfile = grass.tempfile()

    coldescs = [("RC",		"rc integer"),
		("UFI",		"uf1 integer"),
		("UNI",		"uni integer"),
		("LAT",		"lat double precision"),
		("LONG",	"lon double precision"),
		("DMS_LAT",	"dms_lat varchar(6)"),
		("DMS_LONG",	"dms_long varchar(7)"),
		("UTM",		"utm varchar(4)"),
		("JOG",		"jog varchar(7)"),
		("FC",		"fc varchar(1)"),
		("DSG",		"dsg varchar(5)"),
		("PC",		"pc integer"),
		("CC1",		"cci varchar(2)"),
		("ADM1",	"adm1 varchar(2)"),
		("ADM2",	"adm2 varchar(200)"),
		("DIM",		"dim integer"),
		("CC2",		"cc2 varchar(2)"),
		("NT",		"nt varchar(1)"),
		("LC",		"lc varchar(3)"),
		("SHORT_FORM",	"shortform varchar(128)"),
		("GENERIC",	"generic varchar(128)"),
		("SORT_NAME",	"sortname varchar(200)"),
		("FULL_NAME",	"fullname varchar(200)"),
		("FULL_NAME_ND","funamesd varchar(200)"),
		("MODIFY_DATE",	"mod_date date")]

    colnames = [desc[0] for desc in coldescs]
    coltypes = dict([(desc[0], 'integer' in desc[1]) for desc in coldescs])

    header = None
    num_places = 0
    inf = file(fileorig)
    outf = file(tmpfile, 'wb')
    for line in inf:
	fields = line.rstrip('\r\n').split('\t')
	if not header:
	    header = fields
	    continue
	vars = dict(zip(header, fields))
	fields2 = []
	for col in colnames:
	    if col in vars:
		if coltypes[col] and vars[col] == '':
		    fields2.append('0')
		else:
		    fields2.append(vars[col])
	    else:
		if coltypes[col]:
		    fields2.append('0')
		else:
		    fields2.append('')
	line2 = ';'.join(fields2) + '\n'
	outf.write(line2)
	num_places += 1
    outf.close()
    inf.close()

    grass.message(_("Converted %d place names.") % num_places)

    #TODO: fix dms_lat,dms_long DDMMSS -> DD:MM:SS
    # Solution:
    # IN=DDMMSS
    # DEG=`echo $IN | cut -b1,2`
    # MIN=`echo $IN | cut -b3,4`
    # SEC=`echo $IN | cut -b5,6`
    # DEG_STR="$DEG:$MIN:$SEC"
    
    #modifications (to match DBF 10 char column name limit):
    # short_form   -> shortform
    # sort_name    -> sortname
    # full_name    -> fullname
    # full_name_sd -> funamesd

    # pump data into GRASS:

    columns = [desc[1] for desc in coldescs]

    grass.run_command('v.in.ascii', cat = 0, x = 5, y = 4, fs = ';',
		      input = tmpfile, output = filevect,
		      columns = columns)

    grass.try_remove(tmpfile)

    # write cmd history:
    vgrass.vector_history(filevect)
Exemplo n.º 17
0
def cleanup():
    grass.try_remove(tmp)
Exemplo n.º 18
0
def cleanup():
    grass.try_remove(tmp)
    grass.try_remove(tmp + '.dig')
Exemplo n.º 19
0
def main():
    filename = options['file']
    type = options['type']
    vect = options['vect']

    e00tmp = str(os.getpid())

    #### check for avcimport
    if not grass.find_program('avcimport'):
	grass.fatal(_("'avcimport' program not found, install it first") +
		    "\n" +
		    "http://avce00.maptools.org")

    #### check for e00conv
    if not grass.find_program('e00conv'):
	grass.fatal(_("'e00conv' program not found, install it first") +
		    "\n" +
		    "http://avce00.maptools.org")

    # check that the user didn't use all three, which gets past the parser.
    if type not in ['point','line','area']:
	grass.fatal(_('Must specify one of "point", "line", or "area".'))

    e00name = grass.basename(filename, 'e00')
    # avcimport only accepts 13 chars:
    e00shortname = e00name[:13]

    #check if this is a split E00 file (.e01, .e02 ...):
    merging = False
    if os.path.exists(e00name + '.e01') or os.path.exists(e00name + '.E01'):
	grass.message(_("Found that E00 file is split into pieces (.e01, ...). Merging..."))
	merging = True

    if vect:
	name = vect
    else:
	name = e00name

    ### do import

    #make a temporary directory
    tmpdir = grass.tempfile()
    grass.try_remove(tmpdir)
    os.mkdir(tmpdir)

    files = glob.glob(e00name + '.e[0-9][0-9]') + glob.glob(e00name + '.E[0-9][0-9]')
    for f in files:
	shutil.copy(f, tmpdir)

    #change to temporary directory to later avoid removal problems (rm -r ...)
    os.chdir(tmpdir)

    #check for binay E00 file (we can just check if import fails):
    #avcimport doesn't set exist status :-(

    if merging:
	files.sort()
	filename = "%s.cat.%s.e00" % (e00name, e00tmp)
	outf = file(filename, 'wb')
	for f in files:
	    inf = file(f, 'rb')
	    shutil.copyfileobj(inf, outf)
	    inf.close()
	outf.close()

    nuldev = file(os.devnull, 'w+')

    grass.message(_("An error may appear next which will be ignored..."))
    if grass.call(['avcimport', filename, e00shortname], stdout = nuldev, stderr = nuldev) == 1:
	grass.message(_("E00 ASCII found and converted to Arc Coverage in current directory"))
    else:
	grass.message(_("E00 Compressed ASCII found. Will uncompress first..."))
	grass.try_remove(e00shortname)
	grass.try_remove(info)
	grass.call(['e00conv', filename, e00tmp + '.e00'])
	grass.message(_("...converted to Arc Coverage in current directory"))
	grass.call(['avcimport', e00tmp + '.e00', e00shortname], stderr = nuldev)

    #SQL name fix:
    name = name.replace('-', '_')

    ## let's import...
    grass.message(_("Importing %ss...") % type)

    layer = dict(point = 'LAB', line = 'ARC', area = ['LAB','ARC'])
    itype = dict(point = 'point', line = 'line', area = 'centroid')

    if grass.run_command('v.in.ogr', flags = 'o', dsn = e00shortname,
			 layer = layer[type], type = itype[type],
			 output = name) != 0:
	grass.fatal(_("An error occurred while running v.in.ogr"))

    grass.message(_("Imported <%s> vector map <%s>.") % (type, name))

    #### clean up the mess
    for root, dirs, files in os.walk('.', False):
	for f in files:
	    path = os.path.join(root, f)
	    grass.try_remove(path)
	for d in dirs:
	    path = os.path.join(root, d)
	    grass.try_rmdir(path)

    os.chdir('..')
    os.rmdir(tmpdir)
	
    #### end
    grass.message(_("Done."))

    # write cmd history:
    grass.vector_history(name)
Exemplo n.º 20
0
def main():
    layers = options['map'].split(',')

    if len(layers) < 2:
	grass.error(_("At least 2 maps are required"))

    tmpfile = grass.tempfile()

    for map in layers:
	if not grass.find_file(map, element = 'cell')['file']:
	    grass.fatal(_("Raster map <%s> not found") % map)

    grass.write_command('d.text', color = 'black', size = 4, line = 1, stdin = "CORRELATION")

    os.environ['GRASS_PNG_READ'] = 'TRUE'

    colors = "red black blue green gray violet".split()
    line = 2
    iloop = 0
    jloop = 0
    for iloop, i in enumerate(layers):
	for jloop, j in enumerate(layers):
	    if i != j and iloop <= jloop:
		color = colors[0]
		colors = colors[1:]
		colors.append(color)
		grass.write_command('d.text', color = color, size = 4, line = line, stdin = "%s %s" % (i, j))
		line += 1

		ofile = file(tmpfile, 'w')
		grass.run_command('r.stats', flags = 'cnA', input = (i, j), stdout = ofile)
		ofile.close()

		ifile = file(tmpfile, 'r')
		first = True
		for l in ifile:
		    f = l.rstrip('\r\n').split(' ')
		    x = float(f[0])
		    y = float(f[1])
		    if first:
			minx = maxx = x
			miny = maxy = y
			first = False
		    if minx > x: minx = x
		    if maxx < x: maxx = x
		    if miny > y: miny = y
		    if maxy < y: maxy = y
		ifile.close()

		kx = 100.0/(maxx-minx+1)
		ky = 100.0/(maxy-miny+1)

		p = grass.feed_command('d.graph', color = color)
		ofile = p.stdin

		ifile = file(tmpfile, 'r')
		for l in ifile:
		    f = l.rstrip('\r\n').split(' ')
		    x = float(f[0])
		    y = float(f[1])
		    ofile.write("icon + 0.1 %f %f\n" % ((x-minx+1) * kx, (y-miny+1) * ky))
		ifile.close()

		ofile.close()
		p.wait()

    grass.try_remove(tmpfile)
Exemplo n.º 21
0
def main():
    infile = options['input']
    if options['output']:
        outfile = options['output']
    else:
        outfile = infile + '.pack'
    
    global tmp
    tmp = grass.tempdir()
    tmp_dir = os.path.join(tmp, infile)
    os.mkdir(tmp_dir)
    grass.debug('tmp_dir = %s' % tmp_dir)
    
    gfile = grass.find_file(name = infile, element = 'cell')
    if not gfile['name']:
        grass.fatal(_("Raster map <%s> not found") % infile)
    
    if os.path.exists(outfile):
        if os.getenv('GRASS_OVERWRITE'):
            grass.warning(_("Pack file <%s> already exists and will be overwritten") % outfile)
            grass.try_remove(outfile)
        else:
            grass.fatal(_("option <output>: <%s> exists.") % outfile)
    
    grass.message(_("Packing <%s> to <%s>...") % (gfile['fullname'], outfile))
    basedir = os.path.sep.join(gfile['file'].split(os.path.sep)[:-2])
    olddir  = os.getcwd()
    
    # copy elements
    for element in ['cats', 'cell', 'cellhd', 'colr', 'fcell', 'hist']:
        path = os.path.join(basedir, element, infile)
        if os.path.exists(path):
            grass.debug('copying %s' % path)
            shutil.copyfile(path,
                            os.path.join(tmp_dir, element))
            
    if os.path.exists(os.path.join(basedir, 'cell_misc', infile)):
        shutil.copytree(os.path.join(basedir, 'cell_misc', infile),
                        os.path.join(tmp_dir, 'cell_misc'))
        
    if not os.listdir(tmp_dir):
        grass.fatal(_("No raster map components found"))
                    
    # copy projection info
    # (would prefer to use g.proj*, but this way is 5.3 and 5.7 compat)
    gisenv = grass.gisenv()
    for support in ['INFO', 'UNITS']:
        path = os.path.join(gisenv['GISDBASE'], gisenv['LOCATION_NAME'],
                            'PERMANENT', 'PROJ_' + support)
        if os.path.exists(path):
            shutil.copyfile(path, os.path.join(tmp_dir, 'PROJ_' + support))
    
    # pack it all up
    os.chdir(tmp)
    tar = tarfile.TarFile.open(name = outfile, mode = 'w:gz')
    tar.add(infile, recursive = True)
    tar.close()
    try:
        shutil.move(outfile, olddir)
    except shutil.Error, e:
        grass.fatal(e)
Exemplo n.º 22
0
def cleanup():
    grass.try_remove(tmp)
    for f in glob.glob(tmp + '_*'):
	grass.try_remove(f)
Exemplo n.º 23
0
 def close(self):
     self._write()
     np.memmap._close(self)
     grasscore.try_remove(self.filename)
     self._fd = None