[GRASS-dev] Understanding g.tempfile and resolving Illegal filename issues

2013-11-14 Thread Nikos Alexandris
I don't understand how to use g.tempfile. The manual simply refers to (for 
bash): temp1=`g.tempfile pid=$$`

My attempts to use it like that, end up with: Illegal filename. Character / 
not allowed.  Checking if the map's filename exists, returns for example:

--%---
ERROR: Raster map
   /mnemosyne/geo/grassdb/nc_spm_08/landsat/.tmp/Resilience/26834.0
   not found in current mapset
---%--

I have been through the mailing list and have found past references to the 
same problem. For example 
http://lists.osgeo.org/pipermail/grass-user/2012-March/063977.html. However, 
I can't get past the problem.

I tried to use naming conventions such as i.fusion.hpf.tmp.$$ but I still 
have some problems. I would like to use g.tempfile as it seems to be a 
cleaner way(?).

Thank you, Nikos
___
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev


Re: [GRASS-dev] Understanding g.tempfile and resolving Illegal filename issues

2013-11-14 Thread Vaclav Petras
This creates confusion all the time.

For normal files, you use system tools (posix tools) for temporary files,
e.g. mktemp.

For large files (large means large as a map), use g.tempfile which does not
work so well as posix tools in terms of safety but it uses grass database
because there is an assumption that there should be enough space.

For temporary maps there are two way. You can create temporary vector map
in C (and in Python using C types). You cannot do this for rasters. The
universal method is to use unique (enough) map name. Function for this
should be placed to Python library, so we have the standardized method. It
should be noted that `g.tempfile -d` is not usable for this.

I hope that this helps and that it is correct.

Vaclav


On Thu, Nov 14, 2013 at 12:05 PM, Nikos Alexandris
n...@nikosalexandris.netwrote:

 I don't understand how to use g.tempfile. The manual simply refers to (for
 bash): temp1=`g.tempfile pid=$$`

 My attempts to use it like that, end up with: Illegal filename. Character
 /
 not allowed.  Checking if the map's filename exists, returns for
 example:

 --%---
 ERROR: Raster map
/mnemosyne/geo/grassdb/nc_spm_08/landsat/.tmp/Resilience/26834.0
not found in current mapset
 ---%--

 I have been through the mailing list and have found past references to the
 same problem. For example 
 http://lists.osgeo.org/pipermail/grass-user/2012-March/063977.html.
 However, I can't get past the problem.

 I tried to use naming conventions such as i.fusion.hpf.tmp.$$ but I still
 have some problems. I would like to use g.tempfile as it seems to be a
 cleaner way(?).

 Thank you, Nikos
 ___
 grass-dev mailing list
 grass-dev@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/grass-dev

___
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

Re: [GRASS-dev] Understanding g.tempfile and resolving Illegal filename issues

2013-11-14 Thread Hamish
Nikos wrote:
  I don't understand how to use g.tempfile. The manual simply refers to (for
 bash): temp1=`g.tempfile pid=$$`

 My attempts to use it like that, end up with: Illegal filename. Character
 / not allowed.  Checking if the map's filename exists,
 returns for example:

 --%---
 ERROR: Raster map
   /mnemosyne/geo/grassdb/nc_spm_08/landsat/.tmp/Resilience/26834.0
   not found in current mapset
 ---%--

 I have been through the mailing list and have found past references to the
 same problem. For example
 http://lists.osgeo.org/pipermail/grass-user/2012-March/063977.html.
 However, I can't get past the problem.

 I tried to use naming conventions such as i.fusion.hpf.tmp.$$ but I
 still have some problems. I would like to use g.tempfile as it seems
 to be a cleaner way(?).

g.tempfile is for actual files like ascii text files, not for map names.

the convention used in the grass scripts for temporary map names is arbitrary,
but e.g. the g.module command might make one called: tmp_gmodule.$$.elev,
for vector maps replace '.' with '_' and bring out your curly brackets. :)

then cleanup is as simple as g.mremove 'tmp_gmodule.$$.*', and if maps
are left behind it's obvious later that they are temporary and where they
came from.

there's no automatic handling, but I don't see where that would save any time.


what problems did you have with i.fusion.hpf.tmp.$$ ?


Hamish

___
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev


Re: [GRASS-dev] Understanding g.tempfile and resolving Illegal filename issues

2013-11-14 Thread Hamish
Hamish:

 what problems did you have with i.fusion.hpf.tmp.$$ ?
Nikos:
 I think the problem was (among my misunderstanding) that $$
 was the same for a bunch of names fed as variables here and there.

'$$' gets replaced with the PID of the calling process, so within a single 
script it will be consistent, and it should be unique among processes currently 
running on the system.


Hamish

___
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev