Error: Creating GRASS mapset using python script
<p>I am trying to import LANDSAT images into GRASS with a python Script.  I am using the code that has been written on the wiki site: <a href="http://grasswiki.osgeo.org/wiki/LANDSAT" rel="nofollow">http://grasswiki.osgeo.org/wiki/LANDSAT</a> which is copied below:</p>

<pre><code>def import_tifs(mapset2):

    meta = get_timestamp(mapset2)

    for file in os.listdir(mapset2):

        print file

        if os.path.splitext(file)[-1] != '.TIF':
            print file
            continue
        ffile = os.path.join(mapset2, file)
        print ffile
        name = os.path.splitext(file)[0].split('_')[-1]

        print name
        band = int(name[-1])
        print band
        #grass.message('Importing %s -&gt; %s@%s...' % (file, name, mapset))

        grass.run_command('g.mapset',
                          flags = 'c',
                          mapset = mapset2,
                          verbose = True,
                          stderr = open(os.devnull, 'w'))

        grass.run_command('r.in.gdal',
                          input = ffile,
                          output = name,
                          quiet = True,
                          overwrite = False)

        if meta:
            year, month, day = meta['date'].split('-')
            if month == '01':
                month = 'jan'
            elif month == '02':
                month = 'feb'
            elif month == '03':
                month = 'mar'
            elif month == '04':
                month = 'apr'
            elif month == '05':
                month = 'may'
            elif month == '06':
                month = 'jun'
            elif month == '07':
                month = 'jul'
            elif month == '08':
                month = 'aug'
            elif month == '09':
                month = 'sep'
            elif month == '10':
                month = 'oct'
            elif month == '11':
                month = 'nov'
            elif month == '12':
                month = 'dec'

            grass.run_command('r.timestamp',
                              map = name,
                              date = ' '.join((day, month, year)))
</code></pre>

<p>When I run the script I receive the following error:</p>

<pre><code>Traceback (most recent call last):
  File "Process_Landsat.py", line 101, in &lt;module&gt;
    main()
  File "Process_Landsat.py", line 98, in main
    import_tifs(sys.argv[1])
  File "Process_Landsat.py", line 53, in import_tifs
    stderr = open(os.devnull, 'w'))
  File "/usr/lib64/grass-6.4.1/etc/python/grass/script/core.py", line 176, in run_command
    ps = start_command(*args, **kwargs)
  File "/usr/lib64/grass-6.4.1/etc/python/grass/script/core.py", line 164, in start_command
    return Popen(args, **popts)
  File "/usr/lib64/grass-6.4.1/etc/python/grass/script/core.py", line 55, in __init__
    startupinfo, creationflags)
  File "/usr/lib64/python2.6/subprocess.py", line 639, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.6/subprocess.py", line 1228, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
</code></pre>

<p>I have re-read the instructions in the Wiki site, but I cannot get past this error.  Can anyone tell me if I have to have set up any Mapsets/Locations prior to running the script - although it doesn't mention the need to.</p>

<p>Do I need to pass a 'location' or 'gisdbase' argument within the g.mapset subprocess...again, the instructions do not mention the need to.</p>

<p>Thank you in advance for any help</p>

<p>Becky</p>
