[GRASS-user] A Py-script where I check group and delete

2010-10-01 Thread Luisa Peña
Greetings
I have a Python-script where I create a group (using i.group) but, if the
group already exists I need to eliminate (g.remove).

My question is: How can I check, using Python Script code, if a group
already exists?

Thanks
Luisa
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] A Py-script where I check group and delete

2010-10-01 Thread Glynn Clements

Luisa Peña wrote:

 I have a Python-script where I create a group (using i.group) but, if the
 group already exists I need to eliminate (g.remove).
 
 My question is: How can I check, using Python Script code, if a group
 already exists?

import grass.script as grass

if grass.find_file(groupname, 'group)['file']:
...

Or you could just call g.remove anyhow, e.g.

grass.run_command('g.remove',
  group = groupname,
  stderr = file(os.devnull, 'w+'))

-- 
Glynn Clements gl...@gclements.plus.com
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] A Py-script where I check group and delete

2010-10-01 Thread Hamish
Luisa wrote:
 I have a Python-script where I create a group (using i.group)
 but, if the group already exists I need to eliminate (g.remove).
 My question is: How can I check, using Python Script code, if a
 group already exists?

run g.findfile. There could be a grass python library shortcut
for this, I'm not sure, check the python section of the GRASS
Programmer's manual.


Hamish




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